Open jackie-d opened 5 years ago
11-15 16:15:45.634 27694 28035 W AudioManager: Use of stream types is deprecated for operations other than volume control 11-15 16:15:45.634 27694 28035 W AudioManager: See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case
These are warnings, not errors. The W
in this log stands for warning.
Error thrown, no sound.
Can you provide the error? The third parameter in Media
constructor accepts an error callback.
new Media(src, mediaSuccess, [mediaError], [mediaStatus]);
These are the media error codes definitions.
Hi, I already switched out to ionic cordova-plugin-nativeaudio, but I'll give it a try again and let you know as soon as I'll have time.
Thanks
Hello tested again an it gives me a couple of errors:
Codes: 0 and 1
I see 1 it's "MediaError.MEDIA_ERR_ABORTED = 1" (maybe because i'm not providing the path in the form of "cvd://..." but just "assets/mymedia.mp3"?
And what about code 0?
Thanks
May be interesting to note that .record() method works.
I'm suspecting that it's failing in https://github.com/apache/cordova-plugin-media/blob/acffc0c7b16856e888c932628750fc8b29f1db3d/src/android/AudioPlayer.java#L606
Where it will return the MEDIA_ERR_ABORTED
on several caught Exception
errors... without actually printing out the errors (yuck...)
For debugging purposes, you should be able to find this file in the following path:
<cordova-project>/platforms/android/app/src/main/java/org/apache/cordova/media/AudioPlayer.java
Then I'd recommend adding the following line to each of the catch
blocks.
Log.e(LOG_TAG, "exception", e);
It won't fix the MEDIA_ERR_ABORTED
but will hopefully give some more insight in why a MEDIA_ERR_ABORTED
is being passed down inside the android logcat.
Hey, i've done what you asked but no additional log comes out.
11-21 09:52:52.743 20809 21349 W AudioManager: Use of stream types is deprecated for operations other than volume control
11-21 09:52:52.743 20809 21349 W AudioManager: See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case
11-21 09:52:52.745 2013 3400 I MediaFocusControl: requestAudioFocus() from uid/pid 10308/20809 clientId=android.media.AudioManager@a319373org.apache.cordova.media.AudioHandler$1@ffb0230 callingPack=com.aaa.myapp req=1 flags=0x0 sdk=28
11-21 09:52:52.750 20809 20809 D SystemWebChromeClient: http://localhost:8100/consolelogs.js: Line 50 : error sound: {"code":1}
11-21 09:52:52.750 20809 20809 I chromium: [INFO:CONSOLE(50)] "error sound: {"code":1}", source: http://localhost:8100/consolelogs.js (50)
11-21 09:52:52.754 20809 21349 V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
11-21 09:52:52.757 20809 20809 D SystemWebChromeClient: http://localhost:8100/consolelogs.js: Line 50 : error sound: {"code":0}
11-21 09:52:52.758 20809 20809 I chromium: [INFO:CONSOLE(50)] "error sound: {"code":0}", source: http://localhost:8100/consolelogs.js (50)
11-21 09:52:52.789 2013 3400 D PerfShielderService: com.aaa.myapp|com.aaa.myapp/com.aaa.myapp.MainActivity|165|74463027058713|150|5|2
Btw, this is the code i'm relying on to execute, may be some async problem with completion callback to release resource?
private doPlayIOs( clipname: string ) {
const samplePath = this.getSamplePath(clipname);
this.media = new Media(samplePath,
() => {
this.unloadIOs();
},
(error) => {
console.log('error sound: ', JSON.stringify(error));
this.unloadIOs();
}
);
this.media.play();
}
private unloadIOs() {
if ( this.media ) {
try {
this.media.stop();
this.media.release();
} catch ( error ) {
console.log('error releasing media: ', error);
}
}
}
Btw, this is the code i'm relying on to execute, may be some async problem with completion callback to release resource?
I don't see any potential for async race conditions here... but to confirm race condition suspicions I try to wrap my suspect inside a setTimeout
to delay by 1 second or two. Usually if the problem goes away, then there could be a race condition.
Hey, i've done what you asked but no additional log comes out.
My assumptions might have been wrong. If possible are you able to provide a sample reproduction app that contains only what is required to reproduce this issue (pure cordova, without ionic, without your app code, etc). I'd be able to experiment with it further.
I've spent more than a day chasing this. Nothing plays and I get no error condition returned at all. I am using a simple test of just loading the file on device ready and running play. I may be confused as to how to specify access to the sound file. The file is in 'www' and I have tried accessing it using './soundfile', 'file:///android_asset/www/soundfile'.
Bug Report
Problem
11-15 16:15:45.634 27694 28035 W AudioManager: Use of stream types is deprecated for operations other than volume control 11-15 16:15:45.634 27694 28035 W AudioManager: See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case
What is expected to happen?
Sounds play on .play()
What does actually happen?
Error thrown, no sound.
Information
Command or Code
Environment, Platform, Device
Version information
Checklist