require('./bootstrap');
-document.addEventListener("DOMContentLoaded", function() {
-
+document.addEventListener("DOMContentLoaded", function () {
const player = new Plyr('#player');
SCORM.init();
-
+ var interval = setInterval(function () {
+ if (player.duration > 0 && currentTime > (player.duration * (progressComplete / 100))) {
+ SCORM.set('cmi.core.lesson_status', 'completed');
+ SCORM.save();
+ clearInterval(interval);
+ }
+ }, 1000);
});
<body>
@if($type==='audio')
<audio id="player" controls>
- <source src="media.mp3" type="audio/mp3" />
+ <source src="media.mp3" type="audio/mp3"/>
</audio>
@elseif($type==='video')
<video id="player" playsinline controls data-poster="poster.jpg">
- <source src="media.mp4" type="video/mp4" />
+ <source src="media.mp4" type="video/mp4"/>
</video>
@endif
+<script>var progressComplete = {{$media->get('complete_pct')}};</script>
<script src="js/app.js"></script>
</body>
</html>