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

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

问题描述

在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);

,然后按照流教程像<一个href="http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/"相对=nofollow> pocketjourney

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

But this is overly complicated as you can just call

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

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

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