在 MediaPlayer 中将数据源设置为原始 ID [英] Setting data source to an raw ID in MediaPlayer

查看:44
本文介绍了在 MediaPlayer 中将数据源设置为原始 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 MediaPlayer.create 方法中,可以使用原始文件的 ID,但如何在 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);

然后按照流媒体教程,例如 口袋旅行

and then follow a streaming tutorial like pocketjourney

但这太复杂了,你可以直接调用

But this is overly complicated as you can just call

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

这篇关于在 MediaPlayer 中将数据源设置为原始 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆