Create a audio object by using JavaScript code -
i need create popup window , insert content using javascript coding.
now, web page show pop-up when function(camanjs) processed. function output image in dataurl form.and show in pop-up
var w=window.open('about:blank','image canvas'); w.document.write("<img src='"+this.tobase64()+"' alt='from canvas'/>");
i want insert audio 5 second pop-up. , played audio execute function2().
you can encode binary file base64 string , decode. here's example in php encoding:
function encodedaudiostring($type, $file) { return 'data:audio/' . $type . ';base64,' . base64_encode(file_get_contents($file)); }
if want encode , decode in browser, need request file xhr arraybuffer. check link full code: https://github.com/dondido/mp3-to-base64-encoder-and-decoder/blob/master/index.html
then can embed datauri string src of audio
element:
<audio controls src="data:audio/ogg;base64,t2dnuwacaaaaaaaaaaa..........8l3kck">
Comments
Post a Comment