My goal is to split the file and send it to over the other peer into chunks. as the chunks are blobs and i can split the file into blobs but first i want to play a video with the whole blob object in the sender side.
Here is in my code what i am doing is that i am converting the file into the blob object. after doing that i want to read the blob and then play it in html video element but i am failed to play the video. can any one help me, i am stuck here.
here is my code:
videoUpload(event) {
console.log("video event occured");
if (event.target.files && event.target.files[0]) {
var reader2 = new FileReader();
reader2.onload = (event: any) => {
// CAN ANY ONE TELL ME HOW TO PLAY VIDEO BY USING THIS BLOB EVENT
}
**at this stage i am converting my file into the blob**
var file = event.target.files[0];
console.log(file.byteLength);
var chunkSize = 6808850;
var fileSize = file.size;
var chunks = Math.ceil(file.size / chunkSize);
var chunk = 0;
console.log('file size..', fileSize);
console.log('chunks...', chunks);
while (chunk < chunks) {
var offset = chunk * chunkSize;
console.log('current chunk..', chunk);
console.log('offset...', chunk * chunkSize);
console.log('file blob from offset...', offset)
var blob = file.slice(offset, offset + chunkSize);
console.log(blob);
chunk++;
}
// sending the blob to the event listener as array buffer, you can also tell me what "read as" method i can use.
reader2.readAsArrayBuffer(blob);
}
}