【问题标题】:How to send media action button to current player?如何将媒体操作按钮发送到当前播放器?
【发布时间】:2018-03-31 12:36:42
【问题描述】:

有什么方法可以将媒体操作按钮发送到当前媒体播放器(如随身听或谷歌播放音乐)以播放和暂停或下一首和上一首歌曲。

其实我想制作一个简单的遥控器

【问题讨论】:

    标签: android android-mediaplayer media-player mediacontroller


    【解决方案1】:

    我找到了我的答案here

    if (mAudioManager == null) mAudioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
    
    KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY);
    mAudioManager.dispatchMediaKeyEvent(event);
    

    【讨论】:

      猜你喜欢
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多