Reputation:
I'm trying, unsuccessfully, to get the MPMoviePlayerController to play movies silently if the ring/silent switch on the iPhone is set to silent. There are no interface methods to help me out nor does the player respect the AudioSessionProperty() trick:
UInt32 sessionCategory = kAudioSessionCategory_AmbientSound;
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionSetProperty(
kAudioSessionProperty_AudioCategory,
sizeof (sessionCategory),
&sessionCategory);
Has anyone had any success silencing movie playback?
Upvotes: 1
Views: 1484
Reputation: 1540
Add this in your code:
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
Upvotes: 0
Reputation: 4959
MPMoviePlayerController
has a property useApplicationAudioSession
that will allow the player to respect the device's silence setting.
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
player.useApplicationAudioSession = YES;
[player play];
Upvotes: 0
Reputation: 1462
I spent some time trying to get this to work myself. Eventually I gave up after trying, failing and reading this post on the apple dev forums.
"The MPMoviePlayerController establishes its own audio session and there is nothing you can do to affect this"
Upvotes: 1