android - Hey! I wanna save in ExternalStoragePublic file which I receive from the internet, but I really stuck. May you help me with code? -
url = "http://r8---sn-03guxaxjvh-3c2r.googlevideo.com/videoplayback?sparams=dur%2cei%2cid%2cinitcwndbps%2cip%2cipbits%2citag%2clmt%2cmime%2cmm%2cmn%2cms%2cmv%2cpl%2cratebypass%2csource%2cexpire&mn=sn-03guxaxjvh-3c2r&ip=212.113.45.145&source=youtube&mm=31&mv=m&mime=video%2fmp4&mt=1505092537&ipbits=0&initcwndbps=685000&dur=2223.728&id=o-am9pui9o5nsl8p-jgi5-w17xjoo-vvq-trwlmzav17cp&key=yt6&lmt=1499875418101464&signature=4aacc08b22f2f1f343f5a044188cd751a6ad2f08.a7ba661ddc07639a7e414169226a35a700888af3&ms=au&ei=hos1wezyfzfq7gt40rnoaw&itag=22&pl=22&expire=1505114236&ratebypass=yes&title=gothic+rock+-+dark+music"; streamplayer.setaudiostreamtype(audiomanager.stream_music); try { streamplayer.setdatasource(url); } catch (ioexception e) { e.printstacktrace(); } try { streamplayer.prepare(); } catch (ioexception e) { e.printstacktrace(); } streamplayer.start();` my question how store on device streamplayer object?
try this
private static void downloadfile(string url, file outputfile) { try { url u = new url(url); urlconnection conn = u.openconnection(); int contentlength = conn.getcontentlength(); datainputstream stream = new datainputstream(u.openstream()); byte[] buffer = new byte[contentlength]; stream.readfully(buffer); stream.close(); dataoutputstream fos = new dataoutputstream(new fileoutputstream(outputfile)); fos.write(buffer); fos.flush(); fos.close(); } catch(filenotfoundexception e) { return; // swallow 404 } catch (ioexception e) { return; // swallow 404 } }
Comments
Post a Comment