我正在使用以下代码在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];
}
答案 0 :(得分:0)
请参阅在线观看或下载您无论如何要消耗网络带宽的数据。如果您未使用UIWebView
,则可以执行以下任一操作: