@grfzhl/vue-hls-player 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +126 -0
- package/dist/VideoPlayer/BasePlayer.vue +181 -0
- package/dist/VideoPlayer/SubtitleBlock.vue +93 -0
- package/dist/VideoPlayer/VDefaultVideoPlayer.vue +43 -0
- package/dist/VideoPlayer/VPreviewVideoPlayer.vue +33 -0
- package/dist/VideoPlayer/index.vue +55 -0
- package/dist/vue-hls-player.js +3 -0
- package/package.json +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Oliver Schörwerth
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# vue-hls-player
|
|
2
|
+
|
|
3
|
+
## Descriptions
|
|
4
|
+
|
|
5
|
+
It is a video player for the **m3u8** format
|
|
6
|
+
thankfully forked by `LeonidShv/vue-hls-video-player`.
|
|
7
|
+
Customized to make the player themable. Added
|
|
8
|
+
support for showing subtitles / captions of
|
|
9
|
+
the videos.
|
|
10
|
+
|
|
11
|
+
Requirements:
|
|
12
|
+
only for the **vue 3** and **nuxt 3** projects
|
|
13
|
+
|
|
14
|
+
### Examples, how to use component
|
|
15
|
+
```
|
|
16
|
+
npm i vue-hls-player
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
<script setup>
|
|
21
|
+
import { VideoPlayer } from 'vue-hls-player';
|
|
22
|
+
|
|
23
|
+
function processPause(progress) {
|
|
24
|
+
console.log(progress)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const subtitles = [
|
|
28
|
+
{
|
|
29
|
+
link: "subtitles-de.vtt",
|
|
30
|
+
label: "Deutsch",
|
|
31
|
+
lang: "de"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
link: "subtitles-en.vtt",
|
|
35
|
+
label: "English",
|
|
36
|
+
lang: "en"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<VideoPlayer
|
|
43
|
+
type="default"
|
|
44
|
+
@pause="processPause"
|
|
45
|
+
previewImageLink="poster.webp"
|
|
46
|
+
link="videoLink.m3u8"
|
|
47
|
+
:progress="30"
|
|
48
|
+
:isMuted="false"
|
|
49
|
+
:isControls="true"
|
|
50
|
+
:subtitles="subtitles"
|
|
51
|
+
class="customClassName"
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
<VideoPlayer
|
|
55
|
+
type="preview"
|
|
56
|
+
previewImageLink="poster.webp"
|
|
57
|
+
link="videoLink.m3u8"
|
|
58
|
+
class="customClassName"
|
|
59
|
+
/>
|
|
60
|
+
</template>
|
|
61
|
+
```
|
|
62
|
+
For **nuxt 3**, try to wrap this component in ClientOnly, images for previewImageLink need to store in public folder
|
|
63
|
+
```
|
|
64
|
+
<ClientOnly>
|
|
65
|
+
<VideoPlayer
|
|
66
|
+
type="preview"
|
|
67
|
+
previewImageLink="/img/learn.webp"
|
|
68
|
+
link="https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.ism/.m3u8"
|
|
69
|
+
class="customClassName"
|
|
70
|
+
/>
|
|
71
|
+
</ClientOnly>
|
|
72
|
+
```
|
|
73
|
+
### Props:
|
|
74
|
+
**type**:
|
|
75
|
+
1. value: 'default', type: String
|
|
76
|
+
|
|
77
|
+
default video player, where you can process pauses and setup progress time.
|
|
78
|
+
|
|
79
|
+
Default props for the **type: default**:
|
|
80
|
+
```
|
|
81
|
+
:isMuted="false"
|
|
82
|
+
```
|
|
83
|
+
2. value: 'preview', type: String
|
|
84
|
+
|
|
85
|
+
you can pause video on hover, without sound (muted), without controls. It does not have access to props: isMuted, isControls, progress, @pause
|
|
86
|
+
|
|
87
|
+
Default props for the **type: preview**:
|
|
88
|
+
```
|
|
89
|
+
:isMuted="true"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**@pause**:
|
|
93
|
+
1. Event, for processing pauses:
|
|
94
|
+
@pause="processPause"
|
|
95
|
+
```
|
|
96
|
+
function processPause(progress: number) {
|
|
97
|
+
console.log(progress)
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
**previewImageLink**:
|
|
101
|
+
1. value: 'poster.webp', type: String
|
|
102
|
+
|
|
103
|
+
poster image for the video player
|
|
104
|
+
|
|
105
|
+
**link**:
|
|
106
|
+
1. value: 'videoLink.m3u8', type: String
|
|
107
|
+
|
|
108
|
+
link on video in format m3u8
|
|
109
|
+
|
|
110
|
+
**progress**:
|
|
111
|
+
1. value: true or false, type: Boolean
|
|
112
|
+
|
|
113
|
+
it can turn on and off the sound of the video
|
|
114
|
+
|
|
115
|
+
it can show and hide the video control panel
|
|
116
|
+
|
|
117
|
+
**subtitles**:
|
|
118
|
+
1. value: array of object, for subtitles to append: object has link, lang
|
|
119
|
+
|
|
120
|
+
subtitles to add as tracks to the video
|
|
121
|
+
|
|
122
|
+
### Last release:
|
|
123
|
+
v1.0.3
|
|
124
|
+
1. Removed controls in favour of themable overlay by `player.style`.
|
|
125
|
+
2. Updated hls library
|
|
126
|
+
3. Added styled caption overlays. Added separate container to show all captions.
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="video-container">
|
|
3
|
+
<media-theme-sutro>
|
|
4
|
+
<video
|
|
5
|
+
slot="media"
|
|
6
|
+
@pause="pause"
|
|
7
|
+
@ended="pause"
|
|
8
|
+
@keyup="changeSpeed"
|
|
9
|
+
ref="video"
|
|
10
|
+
:poster="previewImageLink"
|
|
11
|
+
:controls="false"
|
|
12
|
+
:title="title"
|
|
13
|
+
controlslist="nodownload"
|
|
14
|
+
playsinline
|
|
15
|
+
crossorigin
|
|
16
|
+
>
|
|
17
|
+
<source
|
|
18
|
+
:src="link"
|
|
19
|
+
type="application/x-mpegURL"
|
|
20
|
+
/>
|
|
21
|
+
<track
|
|
22
|
+
v-if="subtitles.length"
|
|
23
|
+
v-for="(subtitle, i) in subtitles"
|
|
24
|
+
:src="subtitle.link"
|
|
25
|
+
kind="subtitles"
|
|
26
|
+
:srclang="subtitle.lang"
|
|
27
|
+
:label="subtitle.label" :default="i === 0" />
|
|
28
|
+
</video>
|
|
29
|
+
</media-theme-sutro>
|
|
30
|
+
<div ref="subtitlesContainer" class="custom-subtitles"></div>
|
|
31
|
+
</div>
|
|
32
|
+
<SubtitleBlock :vttFile="subtitles[0]" :cursor="videoCursor"></SubtitleBlock>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup>
|
|
36
|
+
import { onMounted, onUpdated, ref, onUnmounted } from 'vue'
|
|
37
|
+
import Hls from 'hls.js'
|
|
38
|
+
import 'player.style/sutro';
|
|
39
|
+
import SubtitleBlock from './SubtitleBlock.vue';
|
|
40
|
+
|
|
41
|
+
const props = defineProps({
|
|
42
|
+
previewImageLink: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: ''
|
|
45
|
+
},
|
|
46
|
+
link: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: ''
|
|
49
|
+
},
|
|
50
|
+
progress: {
|
|
51
|
+
type: Number,
|
|
52
|
+
default: 0
|
|
53
|
+
},
|
|
54
|
+
title: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: ''
|
|
57
|
+
},
|
|
58
|
+
isMuted: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: false
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* array of object, for
|
|
64
|
+
* subtitles to append:
|
|
65
|
+
* object has link, lang ()
|
|
66
|
+
*/
|
|
67
|
+
subtitles: {
|
|
68
|
+
type: Array,
|
|
69
|
+
default: []
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
const emit = defineEmits(['pause', 'test'])
|
|
74
|
+
const video = ref(null)
|
|
75
|
+
const subtitlesContainer = ref(null)
|
|
76
|
+
const videoCursor = ref(0)
|
|
77
|
+
|
|
78
|
+
onMounted(() => {
|
|
79
|
+
prepareVideoPlayer()
|
|
80
|
+
if (video.value) {
|
|
81
|
+
video.value.addEventListener('timeupdate', updateCurrentTime);
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
onUpdated(() => {
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
onUnmounted(() => {
|
|
89
|
+
if (video.value) {
|
|
90
|
+
video.value.removeEventListener('timeupdate', updateCurrentTime);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
function updateCurrentTime() {
|
|
95
|
+
videoCursor.value = video.value.currentTime;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function prepareVideoPlayer() {
|
|
99
|
+
let hls = new Hls()
|
|
100
|
+
let stream = props.link
|
|
101
|
+
hls.loadSource(stream)
|
|
102
|
+
|
|
103
|
+
if (video.value) {
|
|
104
|
+
hls.attachMedia(video.value)
|
|
105
|
+
video.value.muted = props.isMuted
|
|
106
|
+
video.value.currentTime = props.progress
|
|
107
|
+
|
|
108
|
+
const textTracks = video.value.textTracks;
|
|
109
|
+
let previousModes = Array.from(textTracks).map((track) => track.mode);
|
|
110
|
+
function checkTrackModeChanges() {
|
|
111
|
+
Array.from(textTracks).forEach((track, index) => {
|
|
112
|
+
track.addEventListener("cuechange", () => {
|
|
113
|
+
const activeCues = track.activeCues;
|
|
114
|
+
if (activeCues && activeCues.length > 0) {
|
|
115
|
+
subtitlesContainer.value.textContent = activeCues[0].text
|
|
116
|
+
subtitlesContainer.value.style.display = "block";
|
|
117
|
+
} else {
|
|
118
|
+
subtitlesContainer.value.style.display = "none";
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
if (track.mode !== previousModes[index]) {
|
|
122
|
+
console.log(`Track mode changed: ${track.mode}`);
|
|
123
|
+
if (track.mode === "showing") {
|
|
124
|
+
const activeCues = track.activeCues;
|
|
125
|
+
if (activeCues && activeCues.length > 0) {
|
|
126
|
+
subtitlesContainer.value.style.display = "block";
|
|
127
|
+
subtitlesContainer.value.textContent = activeCues[0].text
|
|
128
|
+
} else {
|
|
129
|
+
subtitlesContainer.value.style.display = "none";
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
subtitlesContainer.value.style.display = "none";
|
|
133
|
+
}
|
|
134
|
+
previousModes[index] = track.mode;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
setInterval(checkTrackModeChanges, 100);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function pause() {
|
|
143
|
+
const currentTime = video?.value?.currentTime || 0
|
|
144
|
+
|
|
145
|
+
emit('pause', currentTime)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function changeSpeed(e) {
|
|
149
|
+
if (e.key === 'w' && video && video.value) {
|
|
150
|
+
video.value.playbackRate = video.value.playbackRate + 0.25
|
|
151
|
+
} else if (e.key === 's' && video.value) {
|
|
152
|
+
video.value.playbackRate = video.value.playbackRate - 0.25
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
</script>
|
|
156
|
+
<style>
|
|
157
|
+
video::cue {
|
|
158
|
+
display: none!important;
|
|
159
|
+
text-indent: -999%;
|
|
160
|
+
color: transparent;
|
|
161
|
+
background-color: transparent;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.custom-subtitles {
|
|
165
|
+
position: absolute;
|
|
166
|
+
left: 50%;
|
|
167
|
+
width: auto;
|
|
168
|
+
max-width: 90%;
|
|
169
|
+
text-align: center;
|
|
170
|
+
background: rgba(0, 0, 0, 0.7);
|
|
171
|
+
color: white;
|
|
172
|
+
font-size: 16px;
|
|
173
|
+
font-family: Arial, sans-serif;
|
|
174
|
+
line-height: 1.5;
|
|
175
|
+
padding: 10px 20px;
|
|
176
|
+
border-radius: 10px;
|
|
177
|
+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
|
|
178
|
+
margin-top: -120px;
|
|
179
|
+
transform: translateX(-50%) translateY(-100%);
|
|
180
|
+
}
|
|
181
|
+
</style>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="transcript-container"
|
|
3
|
+
ref="subtitlesContainer">
|
|
4
|
+
<ul v-if="cues.length" class="subtitles">
|
|
5
|
+
<li v-for="cue of cues" :class="{'current-highlight': cursor >= cue.start && cursor <= cue.end}">
|
|
6
|
+
<span class="seconds">{{ secondsToTime(cue.start) }} - {{ secondsToTime(cue.end) }}</span>
|
|
7
|
+
<span class="text">{{ cue.text }}</span>
|
|
8
|
+
</li>
|
|
9
|
+
</ul>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<style lang="css" scoped>
|
|
14
|
+
.subtitles li.current-highlight {
|
|
15
|
+
font-weight: bold;
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
18
|
+
|
|
19
|
+
<script setup>
|
|
20
|
+
import { onMounted, onUpdated, ref } from 'vue'
|
|
21
|
+
|
|
22
|
+
const props = defineProps({
|
|
23
|
+
vttFile: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: ''
|
|
26
|
+
},
|
|
27
|
+
cursor: {
|
|
28
|
+
type: Number,
|
|
29
|
+
default: 0
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const emit = defineEmits(['pause', 'test'])
|
|
34
|
+
const subtitlesContainer = ref(null)
|
|
35
|
+
const cues = ref([])
|
|
36
|
+
|
|
37
|
+
onMounted(async () => {
|
|
38
|
+
cues.value = await parseVTT(props.vttFile.link)
|
|
39
|
+
console.log(cues.value)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
onUpdated(async () => {
|
|
43
|
+
// auto scroll text
|
|
44
|
+
if(subtitlesContainer) {
|
|
45
|
+
const activeSubtitle = subtitlesContainer?.value?.querySelectorAll('li.current-highlight')[0];
|
|
46
|
+
if (activeSubtitle) {
|
|
47
|
+
subtitlesContainer.value.scrollTop = activeSubtitle.offsetTop - subtitlesContainer.value.offsetTop;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
async function parseVTT(fileUrl) {
|
|
54
|
+
const response = await fetch(fileUrl);
|
|
55
|
+
const text = await response.text();
|
|
56
|
+
const cues = [];
|
|
57
|
+
const lines = text.split("\n");
|
|
58
|
+
let cue = null;
|
|
59
|
+
|
|
60
|
+
for (let i = 0; i < lines.length; i++) {
|
|
61
|
+
const line = lines[i].trim();
|
|
62
|
+
if (!line) continue;
|
|
63
|
+
|
|
64
|
+
if (line.includes("-->")) {
|
|
65
|
+
const [start, end] = line.split(" --> ");
|
|
66
|
+
cue = { start: timeToSeconds(start), end: timeToSeconds(end), text: "" };
|
|
67
|
+
} else if (cue) {
|
|
68
|
+
cue.text += line + " ";
|
|
69
|
+
}
|
|
70
|
+
if (cue && (!lines[i + 1] || lines[i + 1].includes("-->"))) {
|
|
71
|
+
cues.push(cue);
|
|
72
|
+
cue = null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return cues;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function timeToSeconds(timestamp) {
|
|
79
|
+
const [hours, minutes, seconds] = timestamp.split(":").map(parseFloat);
|
|
80
|
+
return hours * 3600 + minutes * 60 + seconds;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function secondsToTime(seconds) {
|
|
84
|
+
const hours = Math.floor(seconds / 3600);
|
|
85
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
86
|
+
const secs = Math.floor(seconds % 60);
|
|
87
|
+
const pad = (num) => String(num).padStart(2, '0');
|
|
88
|
+
return `${pad(hours)}:${pad(minutes)}:${pad(secs)}`;
|
|
89
|
+
}
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<BasePlayer
|
|
3
|
+
:previewImageLink="previewImageLink"
|
|
4
|
+
:link="link"
|
|
5
|
+
:progress="progress"
|
|
6
|
+
:isMuted="isMuted"
|
|
7
|
+
:isControls="isControls"
|
|
8
|
+
@pause="pause"
|
|
9
|
+
/>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup>
|
|
13
|
+
import BasePlayer from './BasePlayer.vue'
|
|
14
|
+
|
|
15
|
+
const emit = defineEmits(['pause'])
|
|
16
|
+
|
|
17
|
+
defineProps({
|
|
18
|
+
previewImageLink: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: ''
|
|
21
|
+
},
|
|
22
|
+
link: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: ''
|
|
25
|
+
},
|
|
26
|
+
progress: {
|
|
27
|
+
type: Number,
|
|
28
|
+
default: 0
|
|
29
|
+
},
|
|
30
|
+
isMuted: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
},
|
|
34
|
+
isControls: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: true
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
function pause(currentTime) {
|
|
41
|
+
emit('pause', currentTime)
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<BasePlayer
|
|
3
|
+
:previewImageLink="previewImageLink"
|
|
4
|
+
:link="link"
|
|
5
|
+
:isMuted="true"
|
|
6
|
+
:isControls="false"
|
|
7
|
+
@mouseover="turnOn"
|
|
8
|
+
@mouseleave="turnOff"
|
|
9
|
+
/>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup>
|
|
13
|
+
import BasePlayer from './BasePlayer.vue'
|
|
14
|
+
|
|
15
|
+
defineProps({
|
|
16
|
+
previewImageLink: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: ''
|
|
19
|
+
},
|
|
20
|
+
link: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: ''
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
function turnOn(e) {
|
|
27
|
+
e.target.play()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function turnOff(e) {
|
|
31
|
+
e.target.pause()
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<VDefaultVideoPlayer
|
|
3
|
+
v-if="type === 'default'"
|
|
4
|
+
@pause="pause"
|
|
5
|
+
:previewImageLink="previewImageLink"
|
|
6
|
+
:link="link"
|
|
7
|
+
:progress="progress"
|
|
8
|
+
:isMuted="isMuted"
|
|
9
|
+
:isControls="isControls"
|
|
10
|
+
/>
|
|
11
|
+
|
|
12
|
+
<VPreviewVideoPlayer
|
|
13
|
+
v-else-if="type === 'preview'"
|
|
14
|
+
:previewImageLink="previewImageLink"
|
|
15
|
+
:link="link"
|
|
16
|
+
/>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup>
|
|
20
|
+
import VDefaultVideoPlayer from './VDefaultVideoPlayer.vue'
|
|
21
|
+
import VPreviewVideoPlayer from './VPreviewVideoPlayer.vue'
|
|
22
|
+
|
|
23
|
+
const emit = defineEmits(['pause'])
|
|
24
|
+
|
|
25
|
+
defineProps({
|
|
26
|
+
previewImageLink: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: ''
|
|
29
|
+
},
|
|
30
|
+
link: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: ''
|
|
33
|
+
},
|
|
34
|
+
type: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: ''
|
|
37
|
+
},
|
|
38
|
+
progress: {
|
|
39
|
+
type: Number,
|
|
40
|
+
default: 0
|
|
41
|
+
},
|
|
42
|
+
isMuted: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false
|
|
45
|
+
},
|
|
46
|
+
isControls: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: true
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
function pause(currentTime) {
|
|
53
|
+
emit('pause', currentTime)
|
|
54
|
+
}
|
|
55
|
+
</script>
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@grfzhl/vue-hls-player",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.3",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"main": "./dist/vue-hls-player.js",
|
|
10
|
+
"module": "./dist/vue-hls-player.js",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"m3u8",
|
|
13
|
+
"m3u8 video player",
|
|
14
|
+
"m3u8 vue video",
|
|
15
|
+
"hls video player",
|
|
16
|
+
"hls",
|
|
17
|
+
"vue hls video player",
|
|
18
|
+
"vue hls",
|
|
19
|
+
"caption subtitle"
|
|
20
|
+
],
|
|
21
|
+
"homepage": "https://github.com/grafzahl-io/vue-hls-video-player",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/grafzahl-io/vue-hls-video-player/issues"
|
|
24
|
+
},
|
|
25
|
+
"author": "Oliver Schörwerth",
|
|
26
|
+
"license": "MIT License",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"hls.js": "^1.5.19",
|
|
29
|
+
"player.style": "^0.1.1"
|
|
30
|
+
}
|
|
31
|
+
}
|