简体   繁体   中英

why doesn't MPMoviePlayerController play in simulator but not in device if the format is valid for the device?

Yes, I research what is going on but in my case I am sure the format of the audio is valid because it is m4a file from itunes store preview, which my 4s device plays without any problem.

any tips are appreciated

-(IBAction)StartMusic
{
    NSLog(@"start");

    NSURL *songUrl = [NSURL URLWithString:@"http://a1804.phobos.apple.com/us/r1000/064/Music/v4/9b/b3/c7/9bb3c7dc-a06f-f18c-3e41-2ce1e36f73b4/mzaf_7432104896053262141.aac.m4a"];

    MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:songUrl];

    [[NSNotificationCenter defaultCenter] addObserver:self

                                             selector:@selector(moviePlayBackDidFinish:)

                                                 name:MPMoviePlayerPlaybackDidFinishNotification

                                               object:nil];

    [mp setControlStyle:MPMovieControlStyleFullscreen];
    [mp setMovieSourceType:MPMovieSourceTypeStreaming];

    [mp setFullscreen:YES];
    [mp.view setFrame: self.view.bounds];

    [self.view addSubview:[mp view]];

    [mp prepareToPlay];
    [mp play];

    NSLog(@"start 2");
}

Solved!

I am forcing it playing even if the mute is on,

moviePlayer.useApplicationAudioSession = NO;
[self presentMoviePlayerViewControllerAnimated:moviePlayer];

that's what itunes store does if the mute is on for the preview songs when you tap it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM