How Can I Play Only Those Videos Where Current Time Is Greater Than Start Time Using Java Script? May 23, 2023 Post a Comment Unable to retrieve and play the videos Solution 1: You need to iterate through all the source elements and compare startat attribute. Also note, you should not have multiple id attributes having same value Try this: Baca JugaHow Do Javascript Engine Count Number Of Tag Of The Html Document Is Ill-formed?How To Pass Data To C3 GraphHow To Download File In Browser Using Spring Mvc? $(document).ready(function() { var mediaPlayer = document.getElementById('media-video'); var videoSource = mediaPlayer.getElementsByTagName('source'); var d = new Date(); var hh = d.getHours(); var mm = d.getMinutes(); var ss = d.getSeconds(); var currentTime = hh + ':' + mm + ':' + ss; var a = currentTime.split(':'); var getStartTime = document.getElementById('videosource').getAttribute('startat'); Array.prototype.forEach.call(videoSource, function(elem) { var getStartTime = elem.getAttribute('startat'); if (currentTime >= getStartTime) { alert(elem.getAttribute('name')); var a = currentTime.split(':'); var seconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]); mediaPlayer.currentTime = seconds; mediaPlayer.play(); } }); });Copy <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <video id="media-video" width="600" height="300" src="http://localhost/CastingGallery/upload/2/php.mp4"> <source class="" src="http://localhost/CastingGallery/upload/2/marimatrubhasha.mp4" id="videosource" type="video/mp4" startat="00:00:00" endat="00:04:07" name="Gujarati Bhasha" description="This is Gujarati Video"> <source class="active" src="http://localhost/CastingGallery/upload/2/php.mp4" id="videosource" type="video/mp4" startat="00:04:07" endat="00:19:06" name="PHP Video" description="This is PHP Video"> </video>Copy Fiddle here Share You may like these postsDon't Reload Webpage After Flask Ajax RequestJquery Bpopup Position Popup To My #classValidation For DateGoogle Gantt Chart Shows Wrong Year Post a Comment for "How Can I Play Only Those Videos Where Current Time Is Greater Than Start Time Using Java Script?"
Post a Comment for "How Can I Play Only Those Videos Where Current Time Is Greater Than Start Time Using Java Script?"