简体   繁体   English

Android:Mediaplayer 可以在模拟器上运行,但不能在手机上运行

[英]Android: Mediaplayer works in emulator but not on phone

My Games music plays in the Emulated Phone but not on my actual device (galaxy S7).我的游戏音乐在模拟手机中播放,但不在我的实际设备(galaxy S7)上播放。

myMediaPlayer = MediaPlayer.create(getContext(), R.raw.medieval_loop);
myMediaPlayer.setAudioAttributes(audioAttributes);
myMediaPlayer.setVolume(volume,volume);
myMediaPlayer.start();
audioAttributes = new AudioAttributes.Builder()
            .setUsage(AudioAttributes.USAGE_GAME)
            .setFlags(AudioAttributes.FLAG_AUDIBILITY_ENFORCED)
            .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
            .build();

Anyone had to deal with this before?以前有人处理过这个吗?

Okay the solution was to change my audioattributes to好的解决方案是将我的音频属性更改为

audioAttributes2 = new AudioAttributes.Builder()
                .setUsage(AudioAttributes.USAGE_MEDIA)
                .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
                .build();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android语音到文本可以在模拟器中运行,但不能在手机上运行 - Android speech to text works in emulator but not on phone Android:Internet可以在模拟器中运行,但不能在我的手机上运行 - Android: Internet works in emulator but not on my phone android-android studio模拟器中的SSL问题,可以在手机上正常工作 - android - SSL problems in android studio emulator, works fine on phone Android应用程序可以在真实手机上运行,​​但不能在模拟器上运行-Android开发吗? - Android app works on real phone but not on the emulator - Android Development? GPS Android-无法在实际手机上检索位置,但可以在模拟器上使用 - GPS Android - Cannot retrieve location on actual phone but works on emulator Android:清除并更新手势上的Webview可以在模拟器上而不是手机上运行 - Android: Clear and update webview on gesture works in emulator not on phone Android Studio-具有图像的活动会使模拟器崩溃,但可在手机中使用 - Android Studio - Activity with image crashes emulator but works in phone MediaPlayer可在Android中使用,但进度无法 - MediaPlayer works in Android, but progress does not MediaPlayer可在模拟器上运行,但不能在android中的实际设备上运行 - MediaPlayer working on emulator, but not on actual device in android Android应用程序可在模拟器上运行但不能在手机上运行(“无法调度DDM块XXXX:未定义处理程序”) - Android app works on emulator but not on phone (“Can't dispatch DDM chunk XXXX: no handler defined”)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM