0

I am trying to play a encypted hls content . The contents are chunked using a tool developed locally called chunker .

A catalogue having info about the contents is loaded on the device which wants to play the chunks and is shown as playlist of contents. The catalogue points to the manifest file of each content.

In live scenario, when the chunker is running and chunking the contents, the playback does not start on clicking the playlist, it does not even make a request to the url in d manifest for the decryption key. But the same happens as soon as chunker is stopped .

Exactly similar behaviour happens when trying to play the content using Safari on iPad too.

And now the interesting thing is, this issue doesn't happen with ios simulator or macos and playback is fine but only with iOS device it doesn't play when chunker is running.

Also clear hls content plays just fine on iPad, macos and simulator. No issues with clear content anywhere.

I used iOS 8.2 & 9 iPad and i used Avplayer as player.
Can anybody give me any clue on this ?

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"Trying to play media ");
    NSURL *mediaUrl = [[NSURL alloc]initWithString:[[self.arrMedialist objectAtIndex:indexPath.row]objectForKey:@"url"]];
    // NSURL *mediaUrl = [[NSURL alloc]initWithString:@"http://10.237.166.59/ccad/hls.m3u8"];

    AVPlayer *player = [[AVPlayer alloc]initWithURL:mediaUrl];
    AVPlayerViewController *controller = [[AVPlayerViewController alloc]init];
    controller.player = player;
    controller.showsPlaybackControls = YES;
    [self presentViewController:controller animated:YES completion:nil];
    NSLog(@"playing media url %@ ", mediaUrl);

    [player play];
}
Martin
  • 846
  • 1
  • 9
  • 23
CodeTry
  • 312
  • 1
  • 19

1 Answers1

1

Finally figured out what was the problem. Interesting one though, might help others. For every chunk our chunker was adding an EXT-X-KEY tag for key uri first and the chunk tag or name would get appended just before processing the next chunk, so at anytime the playlist would end with EXT-X-KEY tag . The actual chunk that was corresponding to this tag will be added only after the chunk is created and then again quickly followed by EXT-X-KEY tag for the next chunk. It looks like the player thinks that it read the playlist in the middle of an update (since the chunk for the last EXT-X-KEY tag is not yet updated) and keep trying. When we stop the chunker, the signal is catched and playlist is updated with the last chunk. So, after stopping the player is able to play. And strangely, only iOS has this problem, macos and simulator seem to have handled this case.

CodeTry
  • 312
  • 1
  • 19