iPhone MPMoviePlayerController 在真实设备上播放视频时丢失声音

发布于 2024-08-27 19:22:27 字数 2403 浏览 15 评论 0原文

我在播放时遇到“视频”声音丢失的问题。

我遵循所有标准,但视频/音频有时会静音或在视频文件末尾消失。我不知道为什么。有谁知道可能是什么问题?

仅当在真实设备上运行应用程序时才会发生这种情况,我无法在模拟器上重现该问题。

“didReceiveMemory”警告会导致此问题吗?有时我会在发生这种情况时收到此消息。

视频文件通过 URL 地址进行流式传输,格式为 MPEG-4 电影,大小小于 6.2 MB。

我有以下代码:

- (IBAction) playMovie:(NSString*)theUrl
           setMovieType:(NSString *)theType
          setPlayOption:(int)theOption
setSenderUIButton:(UIButton *)  thisSender
{
    NSString *getvdoUrl = [[NSString alloc]  initWithString:theUrl];
    NSURL *thisVdoURL = [NSURL  URLWithString:getvdoUrl];
    [getvdoUrl release];
    getvdoUrl =  nil;
    MPMoviePlayerController *movieplayer =  [[MPMoviePlayerController alloc]
                        initWithContentURL:thisVdoURL];       
    thisVdoURL = nil;
     if (movieplayer)
    {
        self.vdoPlayer = movieplayer;
         [movieplayer release];
        [[NSNotificationCenter defaultCenter]  addObserver:self
                                                  selector:@selector(moviePlayBackDidFinish:)
                                                      name:MPMoviePlayerPlaybackDidFinishNotification
                                                    object:self.vdoPlayer];
        [self.vdoPlayer play];   
    }

}

-(void)  moviePlayBackDidFinish:(NSNotification*)theNotification
{



     MPMoviePlayerController *movieplayer= [theNotification object];    
      [[NSNotificationCenter defaultCenter] removeObserver:self
      name:MPMoviePlayerPlaybackDidFinishNotification
      object:movieplayer];   
    movieplayer.initialPlaybackTime =  0.0;   
    [movieplayer stop];           
}

下面是警告消息。我在视频文件开始播放之前收到了它们:

warning:  Unable to read symbols for 
"/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.1.3
(7E18)/Symbols/System/Library/VideoDecoders/VCH263.videodecoder"
(file  not found).


warning: Unable to read symbols for 
"/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.1.3
(7E18)/Symbols/System/Library/VideoDecoders/H264H1.videodecoder"
(file  not found).


warning: Unable to read symbols for 
"/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.1.3
(7E18)/Symbols/System/Library/VideoDecoders/MP4VH1.videodecoder"
(file  not found).

2010-03-29 16:57:25.830 ....
v2[4663:207] setting 
file:///private/var/mobile/Applications/7DCB1FCC-7268-4551-B737-8B418CA4A07E/tmp/MediaCache/[html]

I am having issue with losing "video" sound while it was playing.

I followed all the standards but the Video/Audio sometimes gets muted or just disappears at the end of the video file. I have no idea why. Does any know what might be the issue?

This only happens when running the app on the real device, I can't reproduce the issue on the simulator.

Could a "didReceiveMemory" warning cause this? I sometimes receive this message when it happens.

The video file is being streamed via a URL address, format in MPEG-4 Movie, size less than 6.2 MB.

I have the following code:

- (IBAction) playMovie:(NSString*)theUrl
           setMovieType:(NSString *)theType
          setPlayOption:(int)theOption
setSenderUIButton:(UIButton *)  thisSender
{
    NSString *getvdoUrl = [[NSString alloc]  initWithString:theUrl];
    NSURL *thisVdoURL = [NSURL  URLWithString:getvdoUrl];
    [getvdoUrl release];
    getvdoUrl =  nil;
    MPMoviePlayerController *movieplayer =  [[MPMoviePlayerController alloc]
                        initWithContentURL:thisVdoURL];       
    thisVdoURL = nil;
     if (movieplayer)
    {
        self.vdoPlayer = movieplayer;
         [movieplayer release];
        [[NSNotificationCenter defaultCenter]  addObserver:self
                                                  selector:@selector(moviePlayBackDidFinish:)
                                                      name:MPMoviePlayerPlaybackDidFinishNotification
                                                    object:self.vdoPlayer];
        [self.vdoPlayer play];   
    }

}

-(void)  moviePlayBackDidFinish:(NSNotification*)theNotification
{



     MPMoviePlayerController *movieplayer= [theNotification object];    
      [[NSNotificationCenter defaultCenter] removeObserver:self
      name:MPMoviePlayerPlaybackDidFinishNotification
      object:movieplayer];   
    movieplayer.initialPlaybackTime =  0.0;   
    [movieplayer stop];           
}

Below are the warning messages. I received them before the Video file started to play:

warning:  Unable to read symbols for 
"/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.1.3
(7E18)/Symbols/System/Library/VideoDecoders/VCH263.videodecoder"
(file  not found).


warning: Unable to read symbols for 
"/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.1.3
(7E18)/Symbols/System/Library/VideoDecoders/H264H1.videodecoder"
(file  not found).


warning: Unable to read symbols for 
"/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.1.3
(7E18)/Symbols/System/Library/VideoDecoders/MP4VH1.videodecoder"
(file  not found).

2010-03-29 16:57:25.830 ....
v2[4663:207] setting 
file:///private/var/mobile/Applications/7DCB1FCC-7268-4551-B737-8B418CA4A07E/tmp/MediaCache/[html]

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

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

发布评论

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

评论(1

平生欢 2024-09-03 19:22:27

您应该尝试不同的 MP4 文件,它们并不完全相同 - 如果您从 Quicktime 创建它们,它们应该针对流式传输进行优化 - 例如,如果您在 mp4box 的帮助下创建它们,则“提示”。您的文件音频时间戳可能有问题 - 如果有任何问题,请尝试通过 safari 浏览器和/或 Quicktime 播放它。我猜您也遵循 H264 和 AAC 的最大比特率/配置文件/级别设置。

如果您的手机内存确实耗尽,则可能会发生这种情况,媒体播放器在单独的进程中运行,而不是直接在您的应用程序中运行(我想允许它使用 GPU 解码器并将其沙箱化)。
您是否只在应用程序中播放该视频一次?之后会删除通知吗? - 通常在播放视频之前注册一次就足够了。

有些东西取决于你在哪个固件下编译和运行,错误往往会在以后的版本中得到修复,但从 4.0 开始,整个 API 发生了变化,代码也需要更新......

警告消息对于模拟器来说是无用且常见的 - 它们只是来自模拟器试图访问 SDK 之外的模块的调试符号 - 由于模拟器的 Quicktime 运行在您的桌面 Quicktime 中 - 您可能会看到您的声卡驱动程序和更多编解码器,具体取决于您的设置。

You should try a different MP4 file, they are not all equal - they should be optimized for streaming if you are creating them from Quicktime - "hinted" if your create them with the help of mp4box for example. There could be issue with your file audio timestamps - try playing it via safari browser and/or quicktime if there would be any issues . I guess you follow the maximum bitrate/profile/level settings for H264 and AAC as well .

If you really are running out of memory in your phone, this can happen, the mediaplayer runs in separated process- not direcly in your application (I guess to allow it to use GPU decoder and sandbox it).
Are you playing this video just once in the app ? Are you removing the notification afterwards? - it is usually enough to register it just once even before playing video.

Something depends on which firmware are you compiling under and running under, bugs tend to be fixed in later versions, but from 4.0 whole API changed and code needs to be updated as well...

The warning messages are useless and common for simulator - they are just from simulator trying to reach debugging symbols for modules outside of SDK - as simulator's Quicktime runs through your desktop Quicktime - you may see your soundcard driver and more codecs there depending on your setup.

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