视频剪辑不再播放(自动释放问题)

发布于 2024-11-09 10:21:28 字数 1075 浏览 0 评论 0原文

我处理了与 alloc 对象相关的内存泄漏,但是我认为我已经弄乱了我的代码,因为现在我的视频剪辑无法播放。我相信我已在剪辑开始之前释放了设备。有人可以帮我重新排列我的代码吗?我将非常感谢一些让播放再次正常工作的提示。这是我正在使用的示例。

@implementation ELECTRIC_GROOVEYViewController

-(IBAction)playMovie:(id)sender
{
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"1960" ofType:@"m4v"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController =
[[[MPMoviePlayerController alloc] initWithContentURL:fileURL]autorelease];     
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
moviePlayerController.scalingMode = MPMovieScalingModeAspectFill;

[[NSNotificationCenter  defaultCenter] removeObserver:self
                                                 name:MPMoviePlayerLoadStateDidChangeNotification 
                                               object:nil];
// no moviecontrolls
moviePlayerController.controlStyle = MPMovieControlStyleNone;
// looping forever
moviePlayerController.repeatMode= MPMovieRepeatModeOne;


[moviePlayerController play];

}

I took care of a memory leak related to the alloc object, however I think I have fouled up my code as now my video clip does not play. I believe that I have caused the device to release before the clip starts. Could someone help me to rearrange my code? I would be greatly appreciative of a few hints to get playback working again. Here is a sample of what I am working with.

@implementation ELECTRIC_GROOVEYViewController

-(IBAction)playMovie:(id)sender
{
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"1960" ofType:@"m4v"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController =
[[[MPMoviePlayerController alloc] initWithContentURL:fileURL]autorelease];     
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
moviePlayerController.scalingMode = MPMovieScalingModeAspectFill;

[[NSNotificationCenter  defaultCenter] removeObserver:self
                                                 name:MPMoviePlayerLoadStateDidChangeNotification 
                                               object:nil];
// no moviecontrolls
moviePlayerController.controlStyle = MPMovieControlStyleNone;
// looping forever
moviePlayerController.repeatMode= MPMovieRepeatModeOne;


[moviePlayerController play];

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱已欠费 2024-11-16 10:21:28

您正在autoreleasemoviePlayerController对象。它没有进一步的保留。因此,该对象必须被释放。通过创建实例变量来维护对它的引用,并在使用完毕后释放它。

You are autoreleaseing the moviePlayerController object. It has no further retention. Hence the object must be getting deallocated. Maintain a reference to it by creating an instance variable and release it after you are done with it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文