2016-09-30 5 views
0

私はm3u8ストリーミングでiphoneとipadデバイスで完全に動作していますが、Airplay経由でApple Tvでそのストリーミングを再生しようとすると、 AppleTvこのように:アップルのtv(airplay)でm3u8ストリーミングが動作しない

NSURL * url = [NSURL URLWithString:@ "// m3u8 path here"]; AVPlayerItem * playerItem = [AVPlayerItem playerItemWithURL:url];

self.videoPlayer = [AVPlayer playerWithPlayerItem:playerItem]; 
self.playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.videoPlayer]; 
[self.playerLayer setFrame:self.view.frame]; 
[self.view.layer addSublayer:self.playerLayer]; 
[self.videoPlayer play]; 
[self.videoPlayer setAllowsExternalPlayback:YES]; 
self.videoPlayer.usesExternalPlaybackWhileExternalScreenIsActive = YES; 

私は知りません後、私は上記のコード、その後、Apple TVの開始のロードを実行するのApple TVと私の携帯電話を接続し、完全にロードした後、私は私のテレビでのストリーミングの最初の絵を見ると、そのスタックを停止することができますどうして私は他の多くのm3u8リンクを試していますが、リンゴのテレビに貼られたすべてのリンクは誰でも助けて間違っている場所を教えてください.....ありがとう

答えて

0

iosでm3u8ストリームを再生できます。ここで

はサンプルコードです:これは便利です

@property (weak, nonatomic) IBOutlet UIView *playerView; 
@property (nonatomic, strong) AVURLAsset *asset; 
@property (nonatomic, strong) AVPlayer *player; 
@property (nonatomic, strong) AVPlayerItem *playerItem; 

- (IBAction)startStopForwardingVideo:(id)sender 
{ 
    _asset = [AVURLAsset URLAssetWithURL:[NSURL URLWithString:@"http://******sl.m3u8 live stream url"] options:nil]; 
    NSError *error = nil; 
    self.playerItem = [AVPlayerItem playerItemWithAsset:_asset]; 
    [self.player addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:AVPlayerItemStatusContext]; 

    self.player = [[AVPlayer alloc] initWithPlayerItem:self.playerItem]; 
    AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player]; 

    playerLayer.frame = CGRectMake(0, 0, self.playerView.frame.size.width, self.playerView.frame.size.height); 
    playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; 
    [_playerView.layer addSublayer:playerLayer]; 
} 

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context 
{ 
    if ([keyPath isEqualToString:@“status”]) { 

      AVPlayerStatus status = [change[NSKeyValueChangeNewKey] integerValue]; 
      switch (status) { 
       case AVPlayerItemStatusUnknown: 
        break; 
       case AVPlayerItemStatusReadyToPlay: 
       { 
        [self.player play]; 
       } 
      break; 
     case AVPlayerItemStatusFailed: 
      [self stopLoadingAnimationAndHandleError:[[self.player currentItem] error]]; 
      break; 
      } 
    } 
} 

希望

+0

私はオンエアを使用するときにApple TVが動作していない上でのApple TVについて話していますiOSのその作業@Punita –

関連する問題