簡體   English   中英

使用MPMoviePlayerViewController iOS 4.2時,AudioToolbox的iPhone內存泄漏

[英]iPhone Memory Leak from AudioToolbox when using MPMoviePlayerViewController iOS 4.2

我正在使用以下代碼(在選項卡欄應用程序中的視圖控制器內)播放用戶選擇表格行后從主包中加載的視頻。

- (void)loadMoviePlayer:(NSString*)moviePath
{
    NSURL* fileURL    =   [[NSURL alloc] initFileURLWithPath:moviePath];

    MPMoviePlayerViewController* player = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
    [fileURL release];

    [self presentMoviePlayerViewControllerAnimated:player];
    [player release];
}

該應用程序在模擬器中構建和運行時沒有任何明顯問題(我還沒有在設備上進行測試)但是當我通過儀器運行時,在視頻播放期間發生內存泄漏。 Instruments強調AudioToolbox為'Responsible Library'和SimAggregateDevice::SimAggregateDevice(_CFString const*, _CFString const*, long&)

APComponent::CreateDispatchTable(AudioComponentPluginInterface*, unsigned long)

作為“負責任的框架”。

任何你可以在這上面的光都會非常感激! 謝謝。

問題不是“模擬器”本身,而是為Mac OS X編譯的AVFoundation框架。 - Alex Nichol 2011年8月17日23:53

我將Alex的評論設為接受的答案。 ķ

您還可以為iPhone和iPad的電影播放器​​創建自己的自定義控件,您可以在其中創建自定義音量管理,以及許多可以管理的內容。

以下方法啟動moview播放器。 用於管理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];
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM