我使用以下代码(在选项卡栏应用程序的视图控制器内)在用户选择表行后播放从主包加载的视频。
- (void)loadMoviePlayer:(NSString*)moviePath
{
NSURL* fileURL = [[NSURL alloc] initFileURLWithPath:moviePath];
MPMoviePlayerViewController* player = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
[fileURL release];
[self presentMoviePlayerViewControllerAnimated:player];
[player release];
}
该应用程序在模拟器中构建和运行时没有任何明显问题(我尚未在设备上进行测试),但当我通过 Instruments 运行它时,视频播放期间会发生内存泄漏。
Instruments 强调 AudioToolbox 是“负责任的库”,并且SimAggregateDevice::SimAggregateDevice(_CFString const*, _CFString const*, long&)
and
APComponent::CreateDispatchTable(AudioComponentPluginInterface*, unsigned long)
作为“责任框架”。
如果您能对此有所了解,我们将不胜感激!
谢谢。
您还可以为 iPhone 和 iPad 的电影播放器创建自己的自定义控件,您可以在其中创建自定义音量管理,并且可以管理很多事情。
以下方法启动电影播放器。用于管理 mov
-(void)initAndPlayMovie:(NSURL *)movieURL andViewController:(UIViewController*)vCtr
{
self.mPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
// we have movie from file - Alizee :)
[self.mPlayer.moviePlayer setMovieSourceType:MPMovieSourceTypeFile];
// we don't need standard controlls as we have built our own
[self.mPlayer.moviePlayer setControlStyle:MPMovieControlStyleNone];
// aspect fit to screen mode
[self.mPlayer.moviePlayer setScalingMode:MPMovieScalingModeAspectFit];
// full screen mode
[self.mPlayer.moviePlayer setFullscreen:YES animated:YES];
// to start movie player
[vCtr presentMoviePlayerViewControllerAnimated:self.mPlayer];
// now we will add our own view over video player
self.vCtr.view.frame=CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height-20);
[self.mPlayer.view addSubview:self.vCtr.view];
}
- (void)stopTapped:(id)sender{
[self.mPlayer.moviePlayer stop];
}
-(void)moviePlayBackDidFinish:(NSNotification*)notification
{
[self.mPlayer dismissMoviePlayerViewControllerAnimated];
[self.vCtr.view removeFromSuperview];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)