4

我正在尝试在 Phonegap 3.0 中播放和音频文件,在 Windows、android 平台上工作,在 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
4

1 回答 1

1

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

顺便说一句 - 此处的功能确实尽可能使用 PhoneGap Media API 来获取音频。让我知道这是否有帮助。

于 2014-03-05T20:22:48.427 回答