Thank you for your fast response, I will try your suggestion. Merci bcp !
@loicknuchel
Hi, I use you code, now itâs worded.
But I want get the media status, like html5 pased( ).
And when the media end, the media should give me a event, tell me the media is end.
Can you tell me how to do it ?
Thanks.
Hi,
You have the onStatus and onStop callbacks for that.
If you want a method like : getStatus(), you have to save it every time it changed (via onStatus and onStop)
Hi,
I just created a gist with some code sample : https://gist.github.com/loicknuchel/f0222bb66fdaaf7e3391
I added a field status
to media instance to get the current media status.
Tell me if it helps.
ok.
Thank you.
Let me try.
@loicknuchel
Hi,
I want to get mediaStatus info in controllers.js, because services.js canât inject the $scope.
And when the music end, a callback method auto run in my controllers.js.
So, how can I do ?
see https://gist.github.com/loicknuchel/f0222bb66fdaaf7e3391#file-app-js-L18
Il you call myMedia.status
in the method onStop
you will have it⌠But it will always be STOPPED
Thank you for your help.
But I use myMedia.status.code get media status code.
@loicknuchel
Hi, I fix the problem.I add onError() and onStatus(status).
function onError(){
alert(âGet audio errorâ);
}
function onStatus(status){
var audioDuration = $scope.media._duration;
}
good for you! save alot of my time!
Hi ,
I have built an app by using media plugin but i want to automatically pause and resume the media player while getting a call or message.
can you please tell how we can achieve this.
Thanks and Regards
Anil Kumar B
thank you for this, loicknuchel
Hi, from this thread, it sounds like the media plugin does not allow for audio playback while the app is âminimizedâ or âin the backgroundâ, meaning the user navigated away from the app. However, there is this thread on github that suggests it does. Has someone tested this on iOS and Android? Could you please clarify. Thanks!
It does work if I switch the screen off, or switch apps - at least on Android. I heard it works on iOS too!
Thank you so much for the fallback script!!!
You stated âIn Android, the HTML5 audio API is muted, it should be the same on iOS, thatâs why the fallback didnât work.â
How does one unmute that? I can simply pass a mpeg audio stream through an audio element in phonegap with no issues. Why is this an issue in ionic? My audio tags work great in ionic serve, once I build my app I hear nothing.
Hi,
I donât know much but, of course itâ not an issue with Ionic, itâs an issue with android browser.
As you say, it works great on desktop (ionic serve) but not on device, that why you should use the media plugin (sadly, it adds a lot of permissions).
I canât find an option to enable this feature but your user wonât tooâŚ
data-tap-disabled=âtrueâ had to be added to the tag
I have successfully used NativeAudio plugin to play files that are under assets www /audio subfolder.
It works quite well.
The PhoneGap Build page for the plugin
Github page for the plugin
Unfortunately it only works for the files that were bundled with the app.
If you want to download (e.g. with FileTransfer plugin) files and then play them, you can not use that plugin. The reason is that it is coded to use asset folder files (it prefixes path with âwwwâ),
and FileTransfer can not save into assets folder (as per this StackOverflow thread)
So while this plugin does not cover all my needs, it might be of help to you if you only need bundled audio files played.