der*_*lke 16 iphone stream mpmovieplayercontroller media-player ios
我试图通过按下按钮在iPhone上播放来自互联网的视频流.我使用了很多代码示例但没有任何效果.使用此代码,它会打开一个黑色视图,其中没有任何视频流或控件.(流本身有效.)
NSURL *url = [NSURL URLWithString:@"http://MyStreamURL.com"];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
Run Code Online (Sandbox Code Playgroud)
jon*_*oll 27
Instead of creating a MPMoviePlayerController and adding that to your view, it is probably simpler to create a MPMoviePlayerViewController and present that view controller modally (since you are trying to show your video full screen anyway). Then the MPMoviePlayerViewController can manage the presentation of your video for you.
MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
mpvc.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[self presentMoviePlayerViewControllerAnimated:mpvc];
[mpvc release];
Run Code Online (Sandbox Code Playgroud)
在您的moviePlayBackDidFinish委托方法中,您可以关闭模型视图控制器.
| 归档时间: |
|
| 查看次数: |
25867 次 |
| 最近记录: |