gpt4 book ai didi

使用 MPMoviePlayerViewController iOS 4.2 时 AudioToolbox 的 iPhone 内存泄漏

转载 作者:行者123 更新时间:2023-11-28 21:40:56 25 4
gpt4 key购买 nike

我正在使用以下代码(在标签栏应用程序的 View Controller 内)在用户选择表格行后播放从主包加载的视频。

- (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&)

APComponent::CreateDispatchTable(AudioComponentPluginInterface*, unsigned long)

作为“负责框架”。

如果您能对此有所启发,我们将不胜感激!谢谢。

最佳答案

您还可以为 iPhone 和 iPad 的电影播放器​​创建您自己的自定义控件,您可以在其中创建自定义音量管理和许多可以管理的东西。

以下方法启动moview player。用于管理移动

-(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];
}

关于使用 MPMoviePlayerViewController iOS 4.2 时 AudioToolbox 的 iPhone 内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5080922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com