【问题标题】:Is it possible to detect non-ipod music?是否可以检测非 ipod 音乐?
【发布时间】:2012-08-24 00:38:50
【问题描述】:

是否有任何方法可以检测是否正在播放来自 iPod 应用程序以外的其他来源的音乐或媒体?

我知道我可以检测到从 ipod 播放的音乐:

[[MPMusicPlayerController iPodMusicPlayer] playbackState] == MPMusicPlaybackStatePlaying

但是,如果正在播放的音乐来自另一个应用程序,例如 Pandora Radio、Spotify、Plex 等,则返回不正确...我做错了什么还是这可能?

这似乎是可能的,因为这些其他应用程序能够向系统注册以接收系统控制事件

-(void)remoteControlReceivedWithEvent:(UIEvent *)theEvent

但是,到目前为止,除了 ipod 媒体之外,我还没有找到任何查询此值的方法。任何帮助,将不胜感激。谢谢!

【问题讨论】:

  • 我很想知道这一点。

标签: ios mpmusicplayercontroller background-music


【解决方案1】:
static bool isOtherAudioIsPlaying(void)
{
    UInt32 OtherAudioIsPlaying = 0;
    UInt32 size = sizeof(OtherAudioIsPlaying);

    AudioSessionGetProperty(kAudioSessionProperty_OtherAudioIsPlaying,
                 &size,
                 &OtherAudioIsPlaying);
    return (bool)OtherAudioIsPlaying;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-18
    • 2011-01-06
    • 2011-01-17
    • 2015-03-30
    • 2012-01-08
    相关资源
    最近更新 更多