Reputation: 1597
Having a slight problem with MPMoviePlayerController. I am playing a movie and if the user unpluggs the headphones from the audio-jack, it pauses the movie (a standard iOS feature).
However, When the user plugs the headphones back into the jack. The movie doesnt auto resume.
Is there somthing I am missing?
Thanks.
Upvotes: 3
Views: 1172
Reputation: 1983
When will you return the headphones into the jack, your video or music does not continue playing. This feature of iOS.
You need to programmatically determine when the user connected the headphones, and then programmatically to continue playing. To determine the status of headphones, I use the function "propListener" of the sample aurioTouch (from Apple). https://developer.apple.com/library/ios/samplecode/aurioTouch/aurioTouch.zip
Upvotes: 1
Reputation: 3441
MPMoviePlayerController - automatically paused
listen to kAudioSessionProperty_AudioRouteChange property
#import <AudioToolbox/AudioToolbox.h>
void callbackHeadphone_func ( void *inClientData, AudioSessionPropertyID inID, UInt32 inDataSize, const void *inData ) {
if ( inID == kAudioSessionProperty_AudioRouteChange ) {
}
}
- (void) isHeadsetPluggedIn {
UInt32 routeSize = sizeof (CFStringRef); CFStringRef route;
AudioSessionGetProperty (kAudioSessionProperty_AudioRoute, &routeSize, &route);
AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChange, callbackHeadphone_func, self);
/* Known values of route:
"Headset"
"Headphone"
"Speaker"
"SpeakerAndMicrophone"
"HeadphonesAndMicrophone"
"HeadsetInOut"
"ReceiverAndMicrophone"
"Lineout" */
NSString* routeStr = (NSString*)route;
NSLog(@"%@",routeStr);
}
Upvotes: 1