Akamai Token Protection Can't Play IOS

I am an IpTV developer. We have developed our application on Android and now we want to move to IOS devices. Akamai is our CDN. For now, we have a simple IOS app that can play HLS streams. We can navigate through each channel and all streams play correctly. To protect our streams, we planned to use a token. We have already implemented the token on Android, but now I am having some difficulties with IOS. Token protected streams will not play, the screen remains black.

Here is an example of my flow

http: //this_is_my_stream_protected_with_token.m3u8? token = exp = 1432902926 ~ acl = * ~ hmac = 1e1d2afa7e7fbca72b0da6f5820ba1063446631e75fea80093c8183b619c0acc

If I try to play this stream in my app the screen stays black on the other side, if I open VLC or the player in a web browser ( http://www.flashls.org/latest/examples/chromeless/ ) it plays correctly.

I created a function that makes an HTTP request for this link and the server response:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=1629884,CODECS="avc1.77.31,mp4a.40.2",RESOLUTION=640x360
 chunklist.m3u8?__token__=exp%3D1432902926%7Eacl%3D*%7Ehmac%3D1e1d2afa7e7fbca72b0da6f5820ba1063446631e75fea80093c8183b619c0acc

      

To make sure my application is generating the token correctly, I hardcoded it and I still have the same problem.

Since this is not an Akamai issue and a token generation issue, it leads me to believe that maybe I need to encode the stream in the player somehow. I read everywhere about this issue and still don't have a working solution

Here is my player code:

    var param = ["auth":encryption.Token()] as Dictionary<String,String>;
            WebHelper().httpPostNSString(currentChannel.channelTokenUrl, params: param, consumeData: { (nsstring) -> () in

               //this is a custom method. it makes a post HttpRequest. It takes Token Url path and Dictionary with parameters and it returns the respnse data converted to String.

                token = nsstring;
                _URL_ += token;
                _URL_ = _URL_.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet());

               //remove spaces just in case (this is a 'MUST' in Android)

                var address = "http://this_is_my_stream_protected_with_token.m3u8?__token__=exp=1432902926~acl=*~hmac=1e1d2afa7e7fbca72b0da6f5820ba1063446631e75fea80093c8183b619c0acc"

                let url = NSURL(string: address)

                self.moviePlayer = MPMoviePlayerController(contentURL: url)
                self.moviePlayer?.controlStyle = MPMovieControlStyle.None;

                if(self.db.select.getStringValue(forKey: self.db.STRING_VALUE_CURRENT_CHANNEL) == nil){
                    self.db.insert.CoreData_Insert(value: "-1", coreDataKey: self.db.STRING_VALUE_CURRENT_CHANNEL)
                }

                Logs().sendHit(currentChannel.channelNumber, accessway: self.access_way, lastchannel: self.db.select.getStringValue(forKey: self.db.STRING_VALUE_CURRENT_CHANNEL).value, username: self.db.select.getStringValue(forKey: self.db.STRING_VALUE_USERNAME).value);

                self.db.delete.deleteEntityFromCore(entityName: "StringValue", field_Name: "key", field_Value: self.db.STRING_VALUE_CURRENT_CHANNEL);

                self.db.insert.CoreData_Insert(value: currentChannel.channelNumber, coreDataKey: self.db.STRING_VALUE_CURRENT_CHANNEL);

//we save some data and than proceed to play selected channel.

                if let player = self.moviePlayer{

                    //save the new channel

                    player.view.frame = self.view.bounds
                    player.prepareToPlay()
                    player.scalingMode = .AspectFill
                    self.view.addSubview(player.view)
                    self.view.bringSubviewToFront(self.two_way_channel); 
                    player.play();

                    //send hits
                }
            })

      

thank

+3


source to share





All Articles