MPMoviePlayer sound working in Simulators and ipad device, but not Working in iPhone Device
http://stackoverflow.com/questions/9408211/mpmovieplayer-sound-working-in-simulators-and-ipad-device-but-not-working-in-ip
http://stackoverflow.com/questions/5867341/how-to-turn-off-audio-in-mpmovieplayercontroller-iphone
主要就是針對下面設定成NO
useApplicationAudioSession
ex:- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[loadFilmIndicatorView startAnimating];
//設定影片檔路徑
MyManager *sharedManager = [MyManager sharedManager];
NSURL *url = [NSURL URLWithString:sharedManager.playFilmUrl];
// NSString *path = [[NSBundle mainBundle] pathForResource:@"Keep in touch" ofType:@"mp4"];
// url=[NSURL fileURLWithPath:path];
//player為MPMoviePlayerController型態的指標
player = [[MPMoviePlayerController alloc] initWithContentURL:url];
//旋轉90度
player.view.transform = CGAffineTransformMakeRotation(1.5707964);
//設定影片比例的縮放、重複、控制列等參數
player.scalingMode = MPMovieScalingModeAspectFit;
player.repeatMode = MPMovieRepeatModeNone;
player.controlStyle = MPMovieControlStyleFullscreen;//MPMovieControlStyleDefault;
player.useApplicationAudioSession=NO;
//使用Observer製作完成播放時要執行的動作
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePreloadDidFinish:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
//自動縮放符合畫面比例
// player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
NSLog(@"filmurl:%@",sharedManager.playFilmUrl);
[player play];
}
沒有留言:
張貼留言