Reputation: 1263
I am trying to play and audio file in Phonegap 3.0, working on Windows, android platform, debugging in Eclipse.
I am trying to upgrade my working, with no errors, app to 3.0 and am having many problems.
For example, when I play a sound, it plays, then I get a file rename error on a non-existent tmp file from the MediaRecorder API?? However, I am not calling any rename or record.
Here is the log. As you can see the sound file plays fine, then for some reason the MediaRecorder gets called and it trys to rename a tmp file that does not exist. Bare in mind my code has not changed during the upgrade so there is no reason for any of these errors. I am following the media play API from the 3.0 documentation. I also get new Thread Warning errors. The sound file I am playing is a short clip under 100KB.
Plugin has been added using the CLI tool, I have added the feature code to the config.xml file and I have added the permissions to the manifest file. I have read that others are having this problem and there does not seem to be any solution.
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
Upvotes: 4
Views: 883
Reputation: 2296
I feel your pain. I spent a LOT of time getting audio and video playback to work on iOS and ANDROID in my PhoneGap app ... was nearly in tears by time I got things working. Once I got on the other side of that I did what I could to extract the core functionality to a standalone set of files so I could revisit/reuse in future. Feel free to take a look and test out if you want:
BTW - the functionality here does use the PhoneGap Media API for audio when possible. Let me know if this helps at all.
Upvotes: 1