MPMoviePlayerController - 插入耳机后自动恢复

发布于 2025-01-04 11:28:22 字数 143 浏览 5 评论 0原文

MPMoviePlayerController 有一个小问题。我正在播放电影,如果用户从音频插孔拔下耳机,电影就会暂停(标准 iOS 功能)。

但是,当用户将耳机重新插入插孔时。电影不会自动恢复。

我有什么遗漏的吗?

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

MPMoviePlayerController - 自动暂停

监听 kAudioSessionProperty_AudioRouteChange 属性

#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);
    }

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);
    }
陌伤ぢ 2025-01-11 11:28:22

当您将耳机放回插孔时,您的视频或音乐不会继续播放。 iOS的这个功能。

您需要以编程方式确定用户何时连接耳机,然后以编程方式继续播放。
为了确定耳机的状态,我使用示例 aurioTouch(来自 Apple)的函数“propListener”。
https://developer.apple.com/library/ios/samplecode/aurioTouch /aurioTouch.zip

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文