【发布时间】:2011-10-19 05:59:10
【问题描述】:
我正在使用下面的代码在 iPhone 中播放本地电影文件Movie.m4v,使用
MPMoviePlayerController 并且工作正常。
现在我已将同一个文件放入我的在线服务器mobile.sample.com/Downloads/video/Movie.m4v。我想知道如何在 iPhone 中使用上述 URL 播放该电影(而不是使用 uiwebview)。
我怎样才能做到这一点?寻找你的想法。感谢您的帮助。
- (void) readyPlayer
{
mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
if ([mp respondsToSelector:@selector(loadState)])
{
// Set movie player layout
[mp setControlStyle:MPMovieControlStyleFullscreen];
[mp setFullscreen:YES];
// May help to reduce latency
[mp prepareToPlay];
// Register that the load state changed (movie is ready)
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerLoadStateChanged:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
}
else
{
// Register to receive a notification when the movie is in memory and ready to play.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePreloadDidFinish:)
name:MPMoviePlayerContentPreloadDidFinishNotification
object:nil];
}
NSLog(@"ready");
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
}
【问题讨论】:
标签: ios ios4 mpmovieplayercontroller