2016-09-23 66 views
1

我有尝试使用下面的代码打小声音文件的应用程序:MP3/WAV播放的Rhomobile的5.4 Android上

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

当我使用此代码的应用程序抛出一个“服务器错误”是看起来是这样的:

enter image description here

我已经使用媒体播放器API,而不是警报API尝试,而且基本上收到了同样的错误。

这是一个编解码器的问题?

对于WAV文件(是的,WAV文件正确指向,而不是在那些行中的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:in play_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:in serve' 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:in serve' 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”,但我看不出为什么这会起作用。

回答

0

现在已经修复。对于后来的问题,问题是文件位置需要从绝对位置引用,因此可以这样做:

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