Added controll for video playback speed that is saven to localstorage.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<x-layout>
|
||||
|
||||
<h1>
|
||||
<a href="/" class="text-decoration-none">List</a> » <a class="text-decoration-none"
|
||||
href="{{ route('course.index', ['course' => $chapter->course_id]) }}">{{ $chapter->course->name }}</a>
|
||||
@@ -18,10 +19,18 @@
|
||||
</div>
|
||||
<div class="col">
|
||||
@if($videoUrl)
|
||||
<div class="d-flex justify-content-center">
|
||||
<video class="mx-auto" width="500" controls>
|
||||
<source src="{{ $videoUrl }}" type="video/mp4"/>
|
||||
</video>
|
||||
<div class="d-flex justify-content-center flex-column">
|
||||
<div class="p-2">
|
||||
|
||||
<video class="mx-auto" width="500" controls>
|
||||
<source src="{{ $videoUrl }}" type="video/mp4"/>
|
||||
</video>
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<input type="range" id="playback_range" min="0.5" max="4" value="1" step="0.25">
|
||||
<label for="cowbell">playback speed</label>
|
||||
<span id="playback"> </span>
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
no video
|
||||
@@ -32,7 +41,8 @@
|
||||
@foreach($chapters as $courseChapter)
|
||||
<tr class="@if($courseChapter->id === $chapter->id)table-dark @endif">
|
||||
<td>
|
||||
<a href="{{ route('course.chapter', ['course' => $courseChapter->course_id, 'chapter' => $courseChapter->order ]) }}" class="text-decoration-none">{{ $courseChapter->title }}</a>
|
||||
<a href="{{ route('course.chapter', ['course' => $courseChapter->course_id, 'chapter' => $courseChapter->order ]) }}"
|
||||
class="text-decoration-none">{{ $courseChapter->title }}</a>
|
||||
</td>
|
||||
<td class="text-end">{{ $courseChapter->duration }}</td>
|
||||
</tr>
|
||||
@@ -53,4 +63,20 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
const value = document.querySelector("#playback")
|
||||
const input = document.querySelector("#playback_range")
|
||||
document.querySelector('body').onload = function(){
|
||||
const playbackRate = localStorage['playback'] || 1;
|
||||
document.querySelector('video').playbackRate = playbackRate;
|
||||
value.textContent = 'x'+playbackRate;
|
||||
};
|
||||
|
||||
value.textContent = 'x'+input.value
|
||||
input.addEventListener("input", (event) => {
|
||||
localStorage['playback'] = event.target.value;
|
||||
value.textContent = 'x'+event.target.value;
|
||||
document.querySelector('video').playbackRate = event.target.value;
|
||||
})
|
||||
</script>
|
||||
</x-layout>
|
||||
|
||||
Reference in New Issue
Block a user