Search code examples
iosavplayerhttp-live-streamingtimecodes

Using AVPlayer in iOS can you know the current .ts file or the current timestamp from the encoder?


Since we are unable to get Closed caption data or subtitle data out of the AVPlayer, we are looking at other trigger methods, such as timecode or at least the knowledge of the .ts file that is currently active. I couldn't find anything in the documentation and the CMTime from the player doesn't give me the timecode that is embedded in the m3u8 files.

NSLog(@"%f", CMTimeGetSeconds([mPlayer currentTime] ) );

is not what I'm looking for.

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:562
#EXT-X-PROGRAM-DATE-TIME:2020-10-23T14:18:59+08:00
#EXTINF:10,
http://aedsgios1-i.akamaihd.net/hls/live/204775/test1-p/mobile600/Seg_102320_124459_1/mobile600_102320_124459_562.ts
#EXT-X-PROGRAM-DATE-TIME:2020-10-23T14:19:09+08:00
#EXTINF:10,

The EXT-X-PROGRAM-DATE-TIME is what I'm looking to know, or at least the name of the .ts file that is active.

Thanks!


Solution

  • NSLog(@"%@", [[mPlayer currentItem] currentDate ]);