2014-03-03 126 views
7

我有.m3u8鏈接,我需要播放iOS,它支持HLS Protocol在iOS上播放.m3u8文件

當我將URL直接指定給MPMoviePlayerController並播放時,視頻不可見,但我可以聽到音頻。

NSURL *movieURL = [NSURL URLWithString:@"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"]; 
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; 
[self.view addSubview:self.moviePlayer.view]; 

if (mp) 
{ 
    // save the movie player object 
    self.moviePlayer = mp; 
    [self.moviePlayer setFullscreen:YES]; 

    // Play the movie! 
    [self.moviePlayer play]; 
} 

我需要在iOS方面做些什麼額外的事情?

+1

第一分配'self.movi​​ePlayer =熔點;'和設定它到全屏'[self.movi​​ePlayer setFullscreen:YES];'而其中被添加到屏幕的MPMoviePlayerController視圖的代碼? – iCoder

+1

@iCoder:根據您的評論編輯代碼,仍然沒有運氣。 –

+1

檢查出答案! – iCoder

回答

8
NSURL *movieURL = [NSURL URLWithString:@"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"]; 
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; 

if (mp) 
{ 
    mp.view.frame = self.view.bounds; 
    [self.view addSubview:mp.view]; 

    // save the movie player object 
    [mp setFullscreen:YES]; 

    // Play the movie! 
    [mp play]; 

    self.moviePlayer = mp; 
} 
+0

Coooool哥們,像魅力一樣工作。萬分感謝 :) –