语言

Menu
Sites
Language
Reading and Writing Video file

Hi,

     I'm trying to implement a function which read the video file into binary and write it into the user specified location and also upload to the server. I can able to read and write. But after writing the file the new file seems to be currupted. It is not opening in emulator as well as in server.

Note: I'm using readBase64 and writeBase64 for reading and writing the content from filesystem

Thanks

 

编辑者为: Brock Boland 17 3月, 2014 原因: Paragraph tags added automatically from tizen_format_fix module.

响应

4 回复
Lakshmi Grandhi
Hi Aries, Can you please share your code to check the issue.
Aries Brune Tyson Antony Raj
Sure Lakshmi, PFB my code. In wrtieByte i'm writing the date in device as well as passing the videoData(binary data) to server. //To read the video tizen.filesystem.resolve("videos", function(dir){ var file = dir.resolve("Chrome_ImF.mp4"); file.openStream("r",function(stream){ var text=[]; while(!stream.eof) { var tepm2 = stream.readBase64(128); //var tepm2 = stream.readBytes(128); text += tepm2; } stream.close(); writeByte(text); }, function(e){ console.log(e.message) }); //To write the data to video function writeByte(videoData){ tizen.filesystem.resolve("videos", function(dir) { dir.createFile('video.mp4'); file.openStream("w", function(fs) { fs.writeBase64(videoData); fs.close(); console.log("complete"); }, function(e) { console.log("Error " + e.message); }, "UTF-8"); }, function(e) { console.log("Error" + e.message); }, "rw"); }
Lakshmi Grandhi
Hi Aries , The problem is with data to read the stream "var text=[];" you have declared Array to read the data from file, but it is taking DOMString. I have test below code, its working tizen.filesystem.resolve("videos", function(dir){ var file = dir.resolve("sample_iPod.m4v"); file.openStream("r",function(stream){ var text; console.log("length of video"); while(!stream.eof) { console.log("inside stream -------reading" + stream.bytesAvailable); text = stream.readBase64( stream.bytesAvailable); console.log("--------------Stop reading data"); } stream.close(); var file1 = dir.createFile('video.mp4'); file1.openStream("w", function(fs) { console.log("-------File writing ---------"+ text); fs.writeBase64(text); fs.close(); console.log("-------creating another file ---------"); }, function(e){ console.log(e.message); },"UTF-8"); } , function(e){ console.log(e.message); },"UTF-8"); } ); Let me know still if you are facing issues.
Aries Brune Tyson Antony Raj
It works.. Thanks