简体   繁体   English

替代MediaPlayer播放音频文件

[英]Alternative to MediaPlayer to play an audio file

Is there an alternative way of playing audio data other than using MediaPlayer. 除了使用MediaPlayer以外,还有其他播放音频数据的方法。 The audio comes from a resource and not a file. 音频来自资源而不是文件。 I also want it played from a service and not from an activity or using a built-in music player app. 我还希望它从服务而不是从活动或内置的音乐播放器应用播放。 What alternative APIs exist? 存在哪些替代API? I am coming to the conclusion after much testing that MediaPlayer in Android 4.1 is buggy and fails much more than under previous versions, so I am looking for an alternative means of playing audio. 经过大量测试后,我得出的结论是Android 4.1中的MediaPlayer有错误,并且比以前的版本失败更多,因此我正在寻找一种替代的播放音频的方法。

I think the AudioTrack is the best thing to use here. 我认为AudioTrack是在这里使用的最好的东西。 as you are looking to play from resource then you can use raw pcm audio data as resource. 当您希望从资源中播放时,可以将原始的pcm音频数据用作资源。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM