HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 声音仅通过MPMoviePlayerController在某些设备上通过耳机播放大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我对你们都有一个奇怪的问题.

@H_139_5@mPMoviePlayerController正在播放视频,音频只能通过耳机播放.

真正的拖累是,这只发生在一些iPad和iPhone上,甚至是同样的模型
运行相同的系统!

在这里创建了一个简单的失败示例:

http://www.porcaro.org/MPMoviePlayerController/TestMovie.zip

我已经看到它在iPhone 4S,iPhone 4和iPad 2上运行正常并且失败了.

这是最相关的代码.感谢您的任何见解,我也将向Apple提交一个错误

(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];


    moviePath = [NSString StringWithFormat:@"%@/intro.m4v",[[NSBundle mainBundle] bundlePath]];
    NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
    theMoviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

    controlStyle = MPMovieControlStyleEmbedded;
    movieView = [self view];
    movieRect = [[self view] frame];
    controlStyle = MPMovieControlStyleFullscreen;

    theMoviePlayer.controlStyle = controlStyle;
    theMoviePlayer.view.userInteractionEnabled = YES;

    if (1) {
        NSLog(@"Created theMoviePlayer: %@.  Playing: %@",theMoviePlayer,moviePath);
    }

    [[NsnotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlayBACkStateDidChangeNotification object:nil];
    [[NsnotificationCenter defaultCenter] addObserver:self
                                          SELEctor:@SELEctor(checkForEndOfMovie:)
                                          name:MPMoviePlayerPlayBACkStateDidChangeNotification
                                          object:theMoviePlayer];

    // this line doesn't fix the problem                                                                                                       
    //[theMoviePlayer prepareToPlay];                                                                                                          
    [[theMoviePlayer view] setFrame:movieRect];
    [movieView addSubview: [theMoviePlayer view]];
    [theMoviePlayer play];
}

解决方法

这是一个古老的问题,但也许它会帮助某人.我遇到了同样的问题,发现只有手机处于静音模式时才会发生这种情况.

解决方案是将播放器的useApplicationAudioSession属性设置为false.

[theMoviePlayer setUseApplicationAudioSession:NO];

大佬总结

以上是大佬教程为你收集整理的ios – 声音仅通过MPMoviePlayerController在某些设备上通过耳机播放全部内容,希望文章能够帮你解决ios – 声音仅通过MPMoviePlayerController在某些设备上通过耳机播放所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。