IndianaGuy Posted December 13, 2016 Share Posted December 13, 2016 (edited) I have been banging my head all day about this. I am really hoping for some expert guidance. I need to capture and document in a txt file the time ranges played by a user for a media. I needed to end up recording all the ranges played. Feel free to laugh at my code for a bit. I am a super Rookie :-) <? $Name = $_GET["NAME"]; $AccessCode = $_GET["ACCESSCODE"]; $MyTeam = $_GET["MYTEAM"]; $Exposure = $_GET["STORY"]; ?> <audio id="exposure" controls="true" onplayed="myrange()"> <source src="<? echo $Exposure; ?>" type="audio/mpeg" align="middle"> Your browser does not support the audio element. </audio> <script> var FileName = "<?echo $Exposure ;?>"; var LogTo = FileName.replace(/.m4a|.mp3|.wav/,".txt") var Expo = document.getElementById("exposure"); var Prospect = "<? echo $Name ;?>"; var Mem = "<? echo $MyTeam ;?>"; function myrange(){ var Expo = document.getElementById("exposure"); var played = Expo.played; Expo.addEventListener('seeked', function() { for (i = 0; i < Expo.played.length; i++) { var startX = Expo.played.start(i); var endX = Expo.played.end(i) ; var new_startX = convert_time(startX); var new_endX = convert_time(endX); Record_Time(i,new_startX,new_endX); } } // Function to convert the time into a presentable mm:ss format function convert_time(mytime){ var x = Math.round(mytime); var minutes = Math.floor(x / 60); var seconds = x - (minutes * 60); function str_pad_left(string,pad,length) { return (new Array(length+1).join(pad)+string).slice(+length); }; return str_pad_left(minutes,'0',2)+':'+str_pad_left(seconds,'0',2); }; //Function to record time. function RecordTime(L_num,start_time,end_time) { var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", "process.php?length=" + L_num + "&StartTime=" +start_time + "&EndTime=" + end_time, true); xmlhttp.send(); }; </script> </body> </html> Edited December 13, 2016 by IndianaGuy Link to comment Share on other sites More sharing options...
IndianaGuy Posted December 13, 2016 Author Share Posted December 13, 2016 (edited) Can someone just tell me a simple yes or no if this can be done? I cant find much info online. Thank you Edited December 13, 2016 by IndianaGuy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now