2016-09-23 65 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")