Closed tempo-riz closed 9 months ago
okay so after more testing I found that calling release()
after stopRecord()
was working...
Is this normal behavior ?
I can not play radio stream with this plugin, do you have any idea?
@tempo-riz were you able to play .m4a files? I am seeing error 1 (media error abort) with an no supported file type error in the console whenever I try to play an M4a from a stream or the local file system.
@ghenry22 Hey I finally made it work for m4a files (default for ios and android if I remember), this is the code I used hope it helps
let mediaPlayer = new Media(src,
// success callback
() => {
console.log('succes callback')
},
// error callback
(err) => {
console.log(err)
},
(status_codes) => {
console.log(status_codes)
if (status_codes == Media.MEDIA_STARTING || status_codes == Media.MEDIA_RUNNING) {
getMediaPlayerDuration().then(dur => {
duration = dur;
})
}
}
);
//play trigger Media.MEDIA_STARTING and seekto trigger Media.MEDIA_RUNNING (android)
//only play trigger Media.MEDIA_RUNNING (ios)
setTimeout(()=>mediaPlayer.play(), 500); //timeout to avoid crash ios
I think my issue was that I tried to call play() before the media was fully loaded so I added timout and checks. Also another intresting point, for IOS it was working only with relative path for me, so this is how I saved my audio path :
if (app.device.ios) {
path = "../Library/NoCloud/" + Date.now() + ".m4a";
} else {
path = cordova.file.dataDirectory" + Date.now() + ".m4a";
}
Any updates on this? I'm getting the same error on Android!
okay so after more testing I found that calling
release()
afterstopRecord()
was working... Is this normal behavior ?
same here after call .stop() from just playing an audio...
have to execute release() after the 'stop'.
is anyone here also facing a problem of accessing storage? the app is crashing everytime a media file is being accessed
okay so after more testing I found that calling
release()
afterstopRecord()
was working... Is this normal behavior ?
Based on the docs I'd say so.
Releases the underlying operating system's audio resources. This is particularly important for Android, since there are a finite amount of OpenCore instances for media playback. Applications should call the release function for any Media resource that is no longer needed.
It sounds like not calling release
may cause blocking on available OpenCore
resources. I'd imagine the limit on these OpenCore
instances may vary from device, but by not calling release
, you'll eventually hit the instance limit.
Closing because I believe this isn't actually a bug.
Bug Report
audio record works as expected but when I try to
play()
the recorded audio it gives meerror 1
with no other callback triggeringInformation
cordova 11.0.0 cordova android version 11.0.0 media plugin 6.0.0 file plugin 7.0.0
file is saved in file:///data/user/0/appid/files/1662290364345.m4a I also tried playing it from localhost: https://localhost/__cdvfile_files__/1662290364345.m4a
both give error 1 but from localhost there is a delay and the status callback gives 1 before crashing with err 1
I think it was working fine before I updated the plugin...