c# - Audio Stream to Base64 String issue in Windows Phone -


i creating windows phone 8.1 app, have created audio recorder module, , converting audio stream base64string, resulting base64string given below:

"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 

for exact idea, see code below:

public void updatewavheader() {     if (!stream.canseek) throw new exception("can't seek stream update wav header");      var oldpos = stream.position;      stream.seek(4, seekorigin.begin);     stream.write(bitconverter.getbytes((int)stream.length - 8), 0, 4);      stream.seek(40, seekorigin.begin);     stream.write(bitconverter.getbytes((int)stream.length - 44), 0, 4);      stream.seek(oldpos, seekorigin.begin);      isolatedstoragefile isf = isolatedstoragefile.getuserstoreforapplication();      string isovideofilename = "demofile.aac";      if (isf.fileexists(isovideofilename))     {         isf.deletefile(isovideofilename);     }      isovideofile = new isolatedstoragefilestream(isovideofilename, filemode.create, isolatedstoragefile.getuserstoreforapplication());     isovideofile.write(stream.toarray(), 0, stream.toarray().length);      byte[] chunk = new byte[isovideofile.length];     string base64string = convert.tobase64string(chunk); } 

take @ these 2 lines in code:

byte[] chunk = new byte[isovideofile.length]; string base64string = convert.tobase64string(chunk); 

you basicly encoding byte array initialized zero's.

edit:

assuming want encode stream writing .aac file, should trick:

var chunk = stream.toarray();  isovideofile = new isolatedstoragefilestream(isovideofilename, filemode.create, isolatedstoragefile.getuserstoreforapplication()); isovideofile.write(chunk, 0, chunk.length);  //byte[] chunk = new byte[isovideofile.length]; string base64string = convert.tobase64string(chunk); 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -