Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在使用MPMoviePlayerController的某些设备上,仅通过耳机播放声音_Ios_Mpmovieplayercontroller_Iphone 4_Ipad 2 - Fatal编程技术网

Ios 在使用MPMoviePlayerController的某些设备上,仅通过耳机播放声音

Ios 在使用MPMoviePlayerController的某些设备上,仅通过耳机播放声音,ios,mpmovieplayercontroller,iphone-4,ipad-2,Ios,Mpmovieplayercontroller,Iphone 4,Ipad 2,我有一个奇怪的问题要问你们 MPMoviePlayerController可以很好地播放视频,音频只能通过耳机播放 真正的阻力在于,这种情况只发生在一些iPad和iPhone上,甚至是相同的型号 运行相同的精确系统 我在这里创建了一个简单的失败示例: 我看到它在iPhone4S、iPhone4和iPad2上运行良好,但失败了 下面是最相关的代码。感谢您提供的任何见解,我还将向苹果提交一个bug: (void)viewDidAppear:(BOOL)animated { [super v

我有一个奇怪的问题要问你们

MPMoviePlayerController可以很好地播放视频,音频只能通过耳机播放

真正的阻力在于,这种情况只发生在一些iPad和iPhone上,甚至是相同的型号 运行相同的精确系统

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

我看到它在iPhone4S、iPhone4和iPad2上运行良好,但失败了

下面是最相关的代码。感谢您提供的任何见解,我还将向苹果提交一个bug:

(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];
[theMoviePlayer setUseApplicationAudioSession:NO];

这个问题发生在我使用mpMoviePlayer在iPad2上播放视频时。视频播放得非常完美,但音频只有在连接耳机时才能播放

解决问题的解决方案: