How to judge whether a video is playing in Android

        There is an isMusicActive() method in AudioManager, which can be used to determine whether music or video is currently playing.

/**
 * 判断是否在播放音乐或者视频
 * @param context
 * @return
 */
private boolean isMusicOrVideoPlay(Context context){
    AudioManager audioManager = (AudioManager) context.getSystemService(AUDIO_SERVICE);
    return audioManager.isMusicActive();
}

      As above method, call isMusicOrVideoPlay() to know whether the current video is playing.

Guess you like

Origin blog.csdn.net/weixin_42433094/article/details/118910553