数据源设置中的MediaPlayer的原始ID数据源、原始、MediaPlayer、ID

2023-09-05 00:26:35 作者:她是我年少时最冒险的梦@

在MediaPlayer.create方法的ID RAW文件可以使用,但如何使用,在的setDataSource方法?

In MediaPlayer.create method an id to a Raw file can be used but how to use that in setDataSource method?

推荐答案

您可以加载原始音频到一个输入流,并加载到MediaPlayer的,你会正常流:

You can load the raw audio into an input stream and load it into a MediaPlayer as you would a normal stream:

InputStream ins = getResources().openRawResource(R.raw.example);

,然后按照流教程像 pocketjourney

但是,这是过于复杂,你可以叫

But this is overly complicated as you can just call

mp = MediaPlayer.create(counterstrikesb.this, R.raw.example);