jquery - Playing sound from b64 string in ajax result on mobile not working -
i try play sound b64 string ajax request. it's working fine in major browser on desktop pc, not on mobile device (tryed ie, ff (pc , mobile), chrome (pc , mobile) , safari ios). , it's depend of returned content type
code tested :
not working on mobile device without error thrown (and of course work on desktop) :
$.ajax({ type: 'post', url: 'https://api.voicerss.org/', contenttype: 'application/x-www-form-urlencoded; charset=utf-8', data: 'key=mykey&src=hello&hl=fr-fr&r=&c=mp3&f=&ssml=&b64=true', datatype: 'text', success: function (nn) { new audio(nn).play(); } });
and :
$.get('https://api.voicerss.org/', 'key=mykey&src=hello&hl=fr-fr&r=&c=mp3&f=&ssml=&b64=true', function (d, t, j) { new audio(j.responsetext).play(); //or d }, 'text');
work on mobile device :
var aa = new audio(); aa.play() aa.pause(); $.ajax({ type: "post", url: "myurlonmyserver", data: "", contenttype: "application/json; charset=utf-8", datatype: "json", success: function (result) { aa.src = result.d; aa.play(); }, })
and also
var bb = 'data:audio/mpeg;base64,suqzbaaaaaaag...'; new audio(bb).play();
if have ideas...??
thanks
Comments
Post a Comment