android - Android上的Rhomobile 5.4中的Mp3/Wav播放

标签 android audio rhomobile

我有一个尝试使用以下代码播放小型声音文件的应用程序:

Alert.play_file("/public/audio/" + $audio_file + ".mp3", "audio/x-mp3") if Configuration.current.audio_prompt?

当我使用此代码时,应用程序将抛出“服务器错误”,如下所示:

enter image description here

我尝试使用Media Player API而不是Alert API,但收到了基本上相同的错误。

这是编解码器问题吗?

对于Wav文件(是的,wav文件正确指向了这些行中的mp3,而不是mp3),不会引发错误,但声音本身不会播放。

编辑

我终于能够在此错误期间获取一些logcat数据,并收到以下信息:

09-25 19:51:03.122 8891 8948 I APP : I 09/25/2016 19:51:03:122 000022f4 HttpServer| GC End. 09-25 19:51:03.123 8891 8948 I APP : I 09/25/2016 19:51:03:123 000022f4 HttpServer| Process URI: '/app/Animation/draw' 09-25 19:51:03.124 8891 8948 I APP : I 09/25/2016 19:51:03:124 000022f4 APP| RHO serve: /app/Animation/draw 09-25 19:51:03.125 8891 8948 I APP : I 09/25/2016 19:51:03:124 000022f4 APP| Params: {"char_id"=>"6", "ajax"=>"", "run"=>"1"} 09-25 19:51:03.131 500 500 V AudioFlinger: releasing 55 from 8891 for -1 09-25 19:51:03.131 500 500 V AudioFlinger: decremented refcount to 0 09-25 19:51:03.131 500 500 V AudioFlinger: purging stale effects 09-25 19:51:03.132 8891 8948 E ExtMediaPlayer-JNI: QCMediaPlayer could not be located.... 09-25 19:51:03.132 8891 8948 D MediaPlayer-JNI: JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0 09-25 19:51:03.132 8891 8948 E ExtMediaPlayer-JNI: QCMediaPlayer could not be located.... 09-25 19:51:03.132 8891 8948 D MediaPlayer-JNI: JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0 09-25 19:51:03.132 500 4043 V AudioFlinger: acquiring 56 from 8891, for -1 09-25 19:51:03.132 500 4043 V AudioFlinger: added new entry for 56 09-25 19:51:03.133 8891 8948 I APP : E 09/25/2016 19:51:03:133 000022f4 RhoFileApi| Can not open file descriptor: /public/audio/xing4.mp3: open failed: ENOENT (No such file or directory) 09-25 19:51:03.133 8891 8948 I APP : E 09/25/2016 19:51:03:133 000022f4 NotificationSingleton| null 09-25 19:51:03.133 8891 8948 I APP : java.lang.IllegalArgumentException 09-25 19:51:03.133 8891 8948 I APP : at android.media.MediaPlayer._setDataSource(Native Method) 09-25 19:51:03.133 8891 8948 I APP : at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1133) 09-25 19:51:03.133 8891 8948 I APP : at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1118) 09-25 19:51:03.133 8891 8948 I APP : at com.rho.notification.NotificationSingleton.playFile(NotificationSingleton.java:168) 09-25 19:51:03.133 8891 8948 I APP : at com.rho.notification.NotificationSingletonBase$playFileTask.run(NotificationSingletonBase.java:106) 09-25 19:51:03.133 8891 8948 I APP : at com.rhomobile.rhodes.api.MethodExecutor.run(MethodExecutor.java:11) 09-25 19:51:03.133 8891 8948 I APP : E 09/25/2016 19:51:03:133 000022f4 MethodResult| Callback: , data: ; Tab id: -1; resultType: typeError; result: "null" 09-25 19:51:03.134 8891 8948 I APP : I 09/25/2016 19:51:03:133 000022f4 APP| App error: 09-25 19:51:03.134 8891 8948 I APP : lib/RhoNotificationApi.rb:53:in playFile' 09-25 19:51:03.134 8891 8948 I APP : lib/RhoNotificationApi.rb:53:inplay_file' 09-25 19:51:03.134 8891 8948 I APP : apps/app/Animation/animation_controller.rb:273:in draw' 09-25 19:51:03.134 8891 8948 I APP : lib/rho/rhocontroller.rb:101:inserve' 09-25 19:51:03.134 8891 8948 I APP : lib/rho/rhoapplication.rb:217:in serve' 09-25 19:51:03.134 8891 8948 I APP : lib/rho/rho.rb:836:inserve' 09-25 19:51:03.135 8891 8948 I APP : I 09/25/2016 19:51:03:135 000022f4 HttpServer| GC Start. 09-25 19:51:03.153 8891 8891 W cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 8891 09-25 19:51:03.162 8891 8891 I APP : I 09/25/2016 19:51:03:162 000022bb WebViewSingleton| onNavigateComplete <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 09-25 19:51:03.162 721 721 I MSM-irqbalance: Decided to move IRQ115 from CPU0 to CPU3 09-25 19:51:03.244 514 628 E ThermalEngine: ==== Enter sched_bmhb_cs_gov -> vs_temp = 305 === 09-25 19:51:03.250 8891 8948 I APP : I 09/25/2016 19:51:03:250 000022f4 HttpServer| GC End.



似乎最相关的一点是:

RhoFileApi |无法打开文件描述符:/public/audio/xing4.mp3:打开失败:ENOENT(无此文件或目录)

这似乎表明文件丢失或位置错误,但这绝对是我文件所在的位置。

我在这里发现了一些类似问题的帖子:

https://developer.zebra.com/thread/4416

https://developer.zebra.com/thread/1787

但是他们的解决方案不起作用。我没有尝试将公用文件夹中的文件夹明确命名为“alerts”,而不是“audio”,但是我不明白为什么这很重要。

最佳答案

立即修复。对于以后的用户,问题在于文件位置需要从绝对位置引用,因此可以这样做:

Rho::Notification.playFile( Rho::Application.appsBundleFolder + "/public/audio/" + $audio_file + ".mp3", "audio/x-mp3")

关于android - Android上的Rhomobile 5.4中的Mp3/Wav播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39665385/

相关文章:

iphone - RhoStudio 未内置于 XCode - Curl

android - 自定义弹出菜单样式

java - Java中音频是如何存储的

c - 调频合成算法

insert-update - 如何在 Rhomobile 中对 create/update_attributes 的单次调用中插入/更新多条记录

testing - 我将如何以 BDD 风格在 Rhomobile 中测试 Controller ?

android - 使用 Transformations.switchMap 时如何修复 "Required MutableLiveData<String> but ' SwitchMap' 被推断为 LiveData<Y>"?

android - 防止卸载 Android 应用程序

android - 下载/缓存 Google map 以供离线使用

audio - 控制无驱动程序的USB音频设备