i working on phonegap application that, upon pressing button, supposed play 8 seconds long sound clip, while @ same time streaming sound microphone on rtmp wowza server through cordova plugin using ios library videocore.
my problem (on ios exclusively) when sound clip stops playing, microphone - reason - stops recording sound. however, stream still active, resulting in sound clip on server side consisting of 8 seconds of microphone input, complete silence.
commenting out line plays sound results in microphone recoding sound without problem, need able play sound.
defining media variable:
_alarmsound = new media("audio/alarm.mp3") playing sound , starting stream:
if(_streamaudio){ startaudiostream(_alarmid); } if(localstorage.getitem("alarmsound") == "true"){ _alarmsound.play(); } it seems me there kind of internal resource usage conflict occuring when phonegap stops playing sound clip, have no idea can fix it.
i've encountered same problem on ios, , solved doing 2 things:
avaudiosession category
in ios, apps should specify requirements on sound resource using singleton avaudiosession. when using cordova there plugin enables this: https://github.com/eworx/av-audio-session-adapter
so example, when want play sounds set category playback:
audiosession.setcategorywithoptions( avaudiosessionadapter.categories.playback, avaudiosessionadapter.categoryoptions.mix_with_others, successcallback, errorcallback ); and when want record sound using microphone , still able playback sounds set category play_and_record:
audiosession.setcategorywithoptions( avaudiosessionadapter.categories.play_and_record, avaudiosessionadapter.categoryoptions.mix_with_others, successcallback, errorcallback ); cordova-plugin-media kills avaudiosession
the media plugin you're using playback handles both recording , playback in way makes impossible combine other sound plugins , web audio api. deactivates avaudiosession each time has finished playback or recording. since there 1 such session app, deactivates sound in app.
there bug registered this: https://issues.apache.org/jira/browse/cb-11026
since bug still not fixed, , still want use media plugin, way fix download plugin code , comment out/remove lines avaudiosession deactivated:
[self.avsession setactive:no error:nil];
Comments
Post a Comment