Galaxy Tab上的MediaPlayer音频流失败(MediaPlayer audio streaming fails on Galaxy Tab)

系统教程 行业动态 更新时间:2024-06-14 16:58:29
Galaxy Tab上的MediaPlayer音频流失败(MediaPlayer audio streaming fails on Galaxy Tab)

我有一些问题在Galaxy Tab上播放流*音频(适用于HTC Desire HD和Nexus One)。 当我创建MediaPlayer对象时,它会产生如下错误:

02-09 02:21:39.088: VERBOSE/MediaPlayer-JNI(9325): native_setup 02-09 02:21:39.088: VERBOSE/MediaPlayer(9325): constructor 02-09 02:21:39.088: VERBOSE/MediaPlayer(9325): setListener 02-09 02:21:39.092: INFO/MediaPlayer(9325): uri is:http://147.83.39.86:3200/osgi/files/TTS/1297185775715.ogg 02-09 02:21:39.092: INFO/MediaPlayer(9325): path is null 02-09 02:21:39.092: DEBUG/MediaPlayer(9325): Couldn't open file on client side, trying server side 02-09 02:21:39.092: VERBOSE/MediaPlayer-JNI(9325): setDataSource: path http://147.83.39.86:3200/osgi/files/TTS/1297185775715.ogg 02-09 02:21:39.092: VERBOSE/MediaPlayer(9325): setDataSource(http://147.83.39.86:3200/osgi/files/TTS/1297185775715.ogg) 02-09 02:21:39.092: ERROR/MediaPlayerService(2392): Failed to create player object 02-09 02:21:39.092: ERROR/MediaPlayer(9325): Unable to to create media player 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): create failed: 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): java.io.IOException: setDataSource failed.: status=0x80000000 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): at android.media.MediaPlayer.setDataSource(Native Method) 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:745) 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:675) 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): at android.media.MediaPlayer.create(MediaPlayer.java:611) 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): at android.media.MediaPlayer.create(MediaPlayer.java:592) 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): at com.vodafone.inredis.movil.interfazweb.InredisWebViewClient.shouldOverrideUrlLoading(InredisWebViewClient.java:37)

这就是我创建MediaPlayer对象的方式,没有什么奇怪的:

Uri tempPath = Uri.parse(url); player = MediaPlayer.create(interfazWeb, tempPath); if (player != null){ player.start(); } else { Log.e(TAG, "No se puede abrir el audio:" + url); } return true;

为了提供更多信息,我可以说我测试了传递的url,我可以使用本机浏览器下载并正常播放。 显然我可以用桌面浏览器播放它。

anyboedy是否经历过上述设备的这个问题?

提前致谢。

########编辑##############

我还没有解决这个问题,但我一直在研究,现在我在一个单独的线程中下载文件,将其保存到临时文件并使用MediaPlayer打开。 它会产生另一种错误,我怀疑文件夹和权限,但我还不确定。

所以现在我有那些我可以和galaxy的本地播放器一起玩的临时文件,但不是我在我的代码中创建的那个,以及不同的日志跟踪,这没有给我任何暗示。

02-10 01:36:36.945: VERBOSE/MediaPlayer-JNI(8371): native_setup 02-10 01:36:36.945: VERBOSE/MediaPlayer(8371): constructor 02-10 01:36:36.945: VERBOSE/MediaPlayer(8371): setListener 02-10 01:36:36.948: VERBOSE/MediaPlayer-JNI(8371): setDataSource: path /sdcard/audioTmp360988.ogg 02-10 01:36:36.948: VERBOSE/MediaPlayer(8371): setDataSource(/sdcard/audioTmp360988.ogg) 02-10 01:36:36.952: VERBOSE/MediaPlayer(8371): prepare 02-10 01:36:36.952: ERROR/MediaPlayerService(2394): Client::notify In 02-10 01:36:36.952: ERROR/MediaPlayer(8371): message received msg=1, ext1=0, ext2=0 02-10 01:36:36.952: VERBOSE/MediaPlayer(8371): prepared 02-10 01:36:36.952: VERBOSE/MediaPlayer(8371): signal application thread 02-10 01:36:36.952: ERROR/MediaPlayer(8371): callback application 02-10 01:36:36.952: ERROR/MediaPlayer(8371): back from callback 02-10 01:36:36.952: VERBOSE/MediaPlayer(8371): prepare complete - status=0 02-10 01:36:41.437: VERBOSE/MediaPlayer-JNI(8371): native_finalize 02-10 01:36:41.437: VERBOSE/MediaPlayer-JNI(8371): release 02-10 01:36:41.437: VERBOSE/MediaPlayer(8371): setListener 02-10 01:36:41.437: VERBOSE/MediaPlayer(8371): disconnect 02-10 01:36:41.437: VERBOSE/MediaPlayer(8371): destructor 02-10 01:36:41.437: VERBOSE/MediaPlayer(8371): disconnect

来吧,我不可能是唯一一个!

I have some issue playing streaming* audio on a Galaxy Tab (works on HTC Desire HD and Nexus One). When I create the MediaPlayer object, it produces an error like this:

02-09 02:21:39.088: VERBOSE/MediaPlayer-JNI(9325): native_setup 02-09 02:21:39.088: VERBOSE/MediaPlayer(9325): constructor 02-09 02:21:39.088: VERBOSE/MediaPlayer(9325): setListener 02-09 02:21:39.092: INFO/MediaPlayer(9325): uri is:http://147.83.39.86:3200/osgi/files/TTS/1297185775715.ogg 02-09 02:21:39.092: INFO/MediaPlayer(9325): path is null 02-09 02:21:39.092: DEBUG/MediaPlayer(9325): Couldn't open file on client side, trying server side 02-09 02:21:39.092: VERBOSE/MediaPlayer-JNI(9325): setDataSource: path http://147.83.39.86:3200/osgi/files/TTS/1297185775715.ogg 02-09 02:21:39.092: VERBOSE/MediaPlayer(9325): setDataSource(http://147.83.39.86:3200/osgi/files/TTS/1297185775715.ogg) 02-09 02:21:39.092: ERROR/MediaPlayerService(2392): Failed to create player object 02-09 02:21:39.092: ERROR/MediaPlayer(9325): Unable to to create media player 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): create failed: 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): java.io.IOException: setDataSource failed.: status=0x80000000 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): at android.media.MediaPlayer.setDataSource(Native Method) 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:745) 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:675) 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): at android.media.MediaPlayer.create(MediaPlayer.java:611) 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): at android.media.MediaPlayer.create(MediaPlayer.java:592) 02-09 02:21:39.104: DEBUG/MediaPlayer(9325): at com.vodafone.inredis.movil.interfazweb.InredisWebViewClient.shouldOverrideUrlLoading(InredisWebViewClient.java:37)

And this is how I create the MediaPlayer object, nothing weird:

Uri tempPath = Uri.parse(url); player = MediaPlayer.create(interfazWeb, tempPath); if (player != null){ player.start(); } else { Log.e(TAG, "No se puede abrir el audio:" + url); } return true;

And to provide more information, I can say I tested the url passed, and I can download it with the native browser and play it normally. Obviously I can play it with my desktop browser.

Has anyboedy experienced this problem with the mentioned device?

Thanks in advance.

######## EDIT ##############

I haven't solved this issue yet, but I've been researching a bit, now I'm downloading the file in a separate thread, saving it to a temp file and opening with the MediaPlayer. It produces another kind of error, I'm suspecting of the file folders and permissions, but I'm not sure yet.

So now I have those temp files which I can play with the galaxy's native player, but not with the one I create in my code, and a different piece of log trace, which gives me no hint.

02-10 01:36:36.945: VERBOSE/MediaPlayer-JNI(8371): native_setup 02-10 01:36:36.945: VERBOSE/MediaPlayer(8371): constructor 02-10 01:36:36.945: VERBOSE/MediaPlayer(8371): setListener 02-10 01:36:36.948: VERBOSE/MediaPlayer-JNI(8371): setDataSource: path /sdcard/audioTmp360988.ogg 02-10 01:36:36.948: VERBOSE/MediaPlayer(8371): setDataSource(/sdcard/audioTmp360988.ogg) 02-10 01:36:36.952: VERBOSE/MediaPlayer(8371): prepare 02-10 01:36:36.952: ERROR/MediaPlayerService(2394): Client::notify In 02-10 01:36:36.952: ERROR/MediaPlayer(8371): message received msg=1, ext1=0, ext2=0 02-10 01:36:36.952: VERBOSE/MediaPlayer(8371): prepared 02-10 01:36:36.952: VERBOSE/MediaPlayer(8371): signal application thread 02-10 01:36:36.952: ERROR/MediaPlayer(8371): callback application 02-10 01:36:36.952: ERROR/MediaPlayer(8371): back from callback 02-10 01:36:36.952: VERBOSE/MediaPlayer(8371): prepare complete - status=0 02-10 01:36:41.437: VERBOSE/MediaPlayer-JNI(8371): native_finalize 02-10 01:36:41.437: VERBOSE/MediaPlayer-JNI(8371): release 02-10 01:36:41.437: VERBOSE/MediaPlayer(8371): setListener 02-10 01:36:41.437: VERBOSE/MediaPlayer(8371): disconnect 02-10 01:36:41.437: VERBOSE/MediaPlayer(8371): destructor 02-10 01:36:41.437: VERBOSE/MediaPlayer(8371): disconnect

Come on, I can't be the only one!

最满意答案

使用MediaPlayer的WAV和OGG音频流不适用于三星Galaxy TAB(使用FroYo)。 我一直在测试,我使用了API演示(8),特别是/Demos/src/com/example/android/apis/media/MediaPlayerDemo_Audio.java这段代码:

private void playAudio(Integer media) { try { switch (media) { case LOCAL_AUDIO: /** * TODO: Set the path variable to a local audio file path. */ // path = "http://upload.wikimedia.org/wikipedia/commons/a/a9/Tromboon-sample.ogg"; // path = "http://www.robtowns.com/music/blind_willie.mp3"; path = "http://www.nch.com.au/acm/8k16bitpcm.wav"; if (path == "") { // Tell the user to provide an audio file URL. Toast .makeText( MediaPlayerDemo_Audio.this, "Please edit MediaPlayer_Audio Activity, " + "and set the path variable to your audio file path." + " Your audio file must be stored on sdcard.", Toast.LENGTH_LONG).show(); } mMediaPlayer = new MediaPlayer(); Uri tempUri = Uri.parse(path); try { mMediaPlayer.setDataSource(this, tempUri); } catch (IllegalStateException e) { Log.d(TAG, "IllegalStateException: " + e.getMessage()); } catch (IOException e) { Log.d(TAG, "IOException: " + e.getMessage()); } catch (IllegalArgumentException e) { Log.d(TAG, "IllegalArgumentException: " + e.getMessage()); } catch (SecurityException e) { Log.d(TAG, "SecurityException: " + e.getMessage()); } mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.prepare(); mMediaPlayer.start(); break; case RESOURCES_AUDIO: /** * TODO: Upload a audio file to res/raw folder and provide * its resid in MediaPlayer.create() method. */ mMediaPlayer = MediaPlayer.create(this, R.raw.test_cbr); mMediaPlayer.start(); } tx.setText("Playing audio..."); } catch (Exception e) { Log.e(TAG, "error: " + e.getMessage(), e); } }

我只是更改了那些定义要播放的文件路径的3行,以及项目中的任何其他内容。 好吧,只有Mp3文件会播放,WAV和OGG都会产生和异常类似于我的问题。

还有其他人想尝试吗? 我应该假设有一个错误吗?

WAV and OGG Audio Streaming with MediaPlayer does not work on Samsung Galaxy TAB (with FroYo). I've been testing, and I used the API Demo (8), specifically this piece of code at /Demos/src/com/example/android/apis/media/MediaPlayerDemo_Audio.java:

private void playAudio(Integer media) { try { switch (media) { case LOCAL_AUDIO: /** * TODO: Set the path variable to a local audio file path. */ // path = "http://upload.wikimedia.org/wikipedia/commons/a/a9/Tromboon-sample.ogg"; // path = "http://www.robtowns.com/music/blind_willie.mp3"; path = "http://www.nch.com.au/acm/8k16bitpcm.wav"; if (path == "") { // Tell the user to provide an audio file URL. Toast .makeText( MediaPlayerDemo_Audio.this, "Please edit MediaPlayer_Audio Activity, " + "and set the path variable to your audio file path." + " Your audio file must be stored on sdcard.", Toast.LENGTH_LONG).show(); } mMediaPlayer = new MediaPlayer(); Uri tempUri = Uri.parse(path); try { mMediaPlayer.setDataSource(this, tempUri); } catch (IllegalStateException e) { Log.d(TAG, "IllegalStateException: " + e.getMessage()); } catch (IOException e) { Log.d(TAG, "IOException: " + e.getMessage()); } catch (IllegalArgumentException e) { Log.d(TAG, "IllegalArgumentException: " + e.getMessage()); } catch (SecurityException e) { Log.d(TAG, "SecurityException: " + e.getMessage()); } mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.prepare(); mMediaPlayer.start(); break; case RESOURCES_AUDIO: /** * TODO: Upload a audio file to res/raw folder and provide * its resid in MediaPlayer.create() method. */ mMediaPlayer = MediaPlayer.create(this, R.raw.test_cbr); mMediaPlayer.start(); } tx.setText("Playing audio..."); } catch (Exception e) { Log.e(TAG, "error: " + e.getMessage(), e); } }

I just changed those 3 lines defining the path of the file to play, anything else on the project. Well, only the Mp3 file would play, both WAV and OGG produce and exception similar to the one on my question.

Would anybody else like to try? Should I assume there is a bug?

更多推荐

本文发布于:2023-04-15 03:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/c2f40bdd4844402ee225133ebe39bf06.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:音频   MediaPlayer   Tab   Galaxy   streaming

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!