0

AVPlayer オブジェクトを使用して、リモート サーバーから .m3u8 ファイルを取得し、ビデオを再生しました。私のアプリケーションは、.m3u8 ファイルが定期的に更新されるライブ データをストリーミングする必要があります (新しい .ts ファイルが既存のコンテンツに追加されるか、新しい .ts ファイルを追加する前に古いファイルが削除されます)。サーバー データのコンテンツの変更に AVPlayer が応答するようにするにはどうすればよいですか。URLをAVPlayerに再割り当てする正確な方法。以下は簡潔なコードです。お知らせ下さい。

-(void) playVideo{
AVPlayerItem *contentPlayerItem = [[AVPlayerItem alloc]initWithURL:[NSURL URLWithString:contentURL]]; // contentURL contains the path of live streaming data.
self.contentPlayer = [AVPlayer playerWithPlayerItem:contentPlayerItem]; //content player is an object of type AVPlayer
AVPlayerLayer *avPlayerLayer =
  [AVPlayerLayer playerLayerWithPlayer:self.contentPlayer];
//Then I add the AVPlayerLayer object onto my current view after setting its frame.
}

問題は、ビデオが現在再生されていると仮定して、いつ、どのように URL を更新するかです。

4

0 に答える 0