I am creating a simple streaming server for streaming audio / video. the code below does the job, but when I click on the time line in the video, nothing happens, since I cannot get from that time. it is also necessary to send the clikc event to the nodejs streaming and the stream from where I clicked.
I was able to come up with this. I send the file using the URL sendFile = "some file" and then node checks that file. if successful, I will start to receive the stream on my client side, and I put it directly in the src video. But I need morecontrol over this. for example, when a user clicks on a specific timeline so that I can start right there.
app.get is used to determine the location of the folder in which the files are stored. only expression and nodejs are used
function FolderReaderMerger(path,pathToMerge,cb) { log("Reading File/Folder To Combine : "); fs.readdir(path, function(err, audio) { fs.readdir(pathToMerge, function(err, audioText) { var obj ={}; global.list.audio =audio; global.list.audioText =audioText; obj.audio = audio; obj.audioText = audioText; cb(obj); }); }); } app.get("/audio",function(req,resp) { log("App Audio File Serv : "); var playFile = req.param("playFile"); var filePath = {}; filePath.status =false; if(playFile!=undefined) { log("Params File : "+playFile); /* log("Requested URL : "+req.url); log("Total Audio Files : "+global.list.audio.length);*/ var i =0; while(i!=global.list.audio.length) { if(playFile==global.list.audio[i]) { log("File Found : "+playFile); //get files location log(app.get("audioPath")+playFile); filePath.status = true; var filePath = app.get("audioPath")+playFile; log("FILE PATH : "+filePath); var stat = fs.statSync(filePath); log(stat); log(stat.size); resp.writeHead(200, { 'Content-Type': 'audio/mpeg', 'Content-Length': stat.size }); var readStream = fs.createReadStream(filePath); // We replaced all the event handlers with a simple call to readStream.pipe() log("Streaming......."); readStream.pipe(resp); } else { log("Requested Resource Not Found"); } i+=1; } //readStream = fs.createReadStream(app.get("audioPath")); } else { log("Requested Params Not Found"); resp.send(filePath); } }); http.listen(app.get("PORT"),function() { consolelog("--------------------------------------------------------"); console.log("Server Started On PORT: "+app.get("PORT")); console.log("All NPM Initialized"); console.log("Please Wait Checking Connection Status..."); console.log("--------------------------------------------------------"); }); <video src="http://localhost:3000/audio?playFile='some media file"></video>
Any help would be appreciated. This works on the click side.
But you also need more control over the click and events.
source share