Phonegap 3.0 Media API - 破碎?

时间:2013-09-08 22:21:16

标签: javascript android eclipse cordova

我正在尝试播放Phonegap 3.0中的音频文件,在Windows上运行,安卓平台,在Eclipse中进行调试。

我正在尝试升级我的工作,没有错误,应用程序升级到3.0并且遇到很多问题。

例如,当我播放声音时,它会播放,然后我从MediaRecorder API中找到一个不存在的tmp文件的文件重命名错误?但是,我没有调用任何重命名或记录。

  • 看来,一旦对播放声音命令进行成功调用,就会调用声音记录API。 3.0如何运作必定存在一些重大错误。

这是日志。正如您所看到的那样,声音文件播放正常,然后由于某种原因调用MediaRecorder并尝试重命名不存在的tmp文件。请记住,我的代码在升级过程中没有改变,因此没有任何理由可以解决这些错误。我正在关注3.0文档中的媒体播放API。我也得到新的线程警告错误。我正在播放的声音文件是100KB以下的短片。

使用CLI工具添加了插件,我已将功能代码添加到config.xml文件中,并且我已将权限添加到清单文件中。我已经读过其他人遇到这个问题,而且似乎没有任何解决方案。

09-08 15:06:07.821: D/webview(9279): [WebView::UPDATE_SELECTION] ====== start
09-08 15:06:07.951: V/MediaRecorderJNI(9279): setup
09-08 15:06:07.951: V/MediaRecorderJNI(9279): setMediaRecorder E: mr = mr
09-08 15:06:07.951: V/MediaRecorderJNI(9279): setMediaRecorder X

09-08 15:06:07.961: W/PluginManager(9279): THREAD WARNING: exec() call to Media.create blocked the main thread for 31ms. Plugin should use CordovaInterface.getThreadPool().

09-08 15:06:07.961: I/AudioSystem(9279): getting audio flinger
09-08 15:06:07.961: I/AudioSystem(9279): returning new audio session id
09-08 15:06:07.971: D/MediaPlayer(9279): setDataSource(FileDescriptor fd) in
09-08 15:06:07.981: D/dalvikvm(9279): GC_CONCURRENT freed 421K, 49% free 3166K/6151K, external 0K/0K, paused 2ms+3ms
09-08 15:06:08.021: D/MediaPlayer(9279): setDataSource(FileDescriptor fd) out

09-08 15:06:08.041: W/PluginManager(9279): THREAD WARNING: exec() call to Media.startPlayingAudio blocked the main thread for 78ms. Plugin should use CordovaInterface.getThreadPool().

09-08 15:06:08.041: D/CordovaLog(9279): file:///android_asset/www/js/test.js: Line 1463 : maxTempCount: 1
09-08 15:06:08.041: I/Web Console(9279): maxTempCount: 1 at file:///android_asset/www/js/test.js:1463
09-08 15:06:08.041: D/AudioPlayer(9279): Send a onStatus update for the new seek
09-08 15:06:08.041: D/MediaPlayer(9279): start() in
09-08 15:06:08.051: D/MediaPlayer(9279): start() out
09-08 15:06:11.465: D/AudioPlayer(9279): on completion is calling stopped

09-08 15:06:11.545: D/CordovaLog(9279): file:///android_asset/www/js/test.js: Line 1391 : playAudio():Audio Success: sound.mp3
09-08 15:06:11.545: I/Web Console(9279): playAudio():Audio Success: sound.mp3 at file:///android_asset/www/js/test.js:1391

09-08 15:06:11.555: D/MediaPlayer(9279): release() in
09-08 15:06:11.565: D/MediaPlayer(9279): release() out
09-08 15:06:11.565: V/MediaRecorderJNI(9279): native_reset

09-08 15:06:11.565: V/MediaRecorderJNI(9279): getMediaRecorder E
09-08 15:06:11.565: V/MediaRecorderJNI(9279): process_media_recorder_call
09-08 15:06:11.565: D/AudioPlayer(9279): renaming /mnt/sdcard/tmprecording.3gp to /mnt/sdcard/Downloaded/sound.mp3

09-08 15:06:11.565: E/AudioPlayer(9279): FAILED renaming /mnt/sdcard/tmprecording.3gp to /mnt/sdcard/Downloaded/sound.mp3

09-08 15:06:11.565: V/MediaRecorderJNI(9279): release
09-08 15:06:11.565: V/MediaRecorderJNI(9279): setMediaRecorder E: mr = null
09-08 15:06:11.575: V/MediaRecorderJNI(9279): setMediaRecorder X

09-08 15:06:11.575: W/PluginManager(9279): THREAD WARNING: exec() call to Media.release blocked the main thread for 19ms. Plugin should use CordovaInterface.getThreadPool().

09-08 15:06:11.585: D/CordovaLog(9279): file:///android_asset/www/js/test.js: Line 1628 : ==LOG== flag: sound.mp3 result: 3
09-08 15:06:11.585: I/Web Console(9279): ==LOG== flag: sound.mp3 result: 3 at file:///android_asset/www/js/test.js:1628

1 个答案:

答案 0 :(得分:1)

我感觉到你的痛苦。我花了很多时间在我的PhoneGap应用程序中将音频和视频播放工作在iOS和ANDROID上工作......当我开始工作时,我几乎要流泪了。一旦我站到了另一边,我尽我所能将核心功能提取到一组独立的文件中,以便将来重新访问/重用。如果您愿意,请随意查看并测试:

顺便说一句 - 这里的功能尽可能使用PhoneGap Media API来播放音频。如果这有帮助,请告诉我。