@mindedge/vuetify-player 0.1.3 → 0.2.0

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.
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ presets: ['@vue/cli-plugin-babel/preset'],
3
+ }
package/jest.config.js ADDED
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ preset: '@vue/cli-plugin-unit-jest',
3
+ }
package/jsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "module": "esnext",
5
+ "baseUrl": "./",
6
+ "moduleResolution": "node",
7
+ "paths": {
8
+ "@/*": ["src/*"]
9
+ },
10
+ "lib": ["esnext", "dom", "dom.iterable", "scripthost"]
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,18 +1,16 @@
1
1
  {
2
2
  "name": "@mindedge/vuetify-player",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "description": "Accessible, localized, full featured media player with Vuetifyjs",
6
6
  "author": "Jacob Rogaishio",
7
7
  "scripts": {
8
- "serve": "vue-cli-service serve",
9
- "build": "vue-cli-service build --target lib --name VuetifyPlayer src/index.js",
10
8
  "test:unit": "vue-cli-service test:unit",
11
9
  "lint": "vue-cli-service lint",
12
10
  "i18n:report": "vue-cli-service i18n:report --src \"./src/**/*.?(js|vue)\" --locales \"./src/locales/**/*.json\"",
13
11
  "lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore ."
14
12
  },
15
- "main": "./dist/VuetifyPlayer.umd.min.js",
13
+ "main": "./src/components/VuetifyPlayer.vue",
16
14
  "dependencies": {
17
15
  "@intlify/vue-i18n-loader": "^1.1.0",
18
16
  "core-js": "^3.8.3",
@@ -0,0 +1,128 @@
1
+ <template>
2
+ <v-card>
3
+ <v-card-text>
4
+ <v-list ref="captionList" class="captions-list">
5
+ <v-list-item-group v-model="captionIndex">
6
+ <v-list-item
7
+ ref="captionItems"
8
+ v-for="(cue, index) in captions.cues"
9
+ :key="index"
10
+ @click="onCueClick(cue.startTime)"
11
+ >
12
+ <v-list-item-icon>
13
+ <v-icon
14
+ >{{
15
+ index === captionIndex
16
+ ? 'mdi-arrow-right-drop-circle-outline'
17
+ : 'mdi-checkbox-blank-circle-outline'
18
+ }}
19
+ </v-icon>
20
+ </v-list-item-icon>
21
+ <v-list-item-content
22
+ v-html="cue.text"
23
+ ></v-list-item-content>
24
+ <v-list-item-action>
25
+ <span aria-hidden="true">
26
+ {{ filters.playerShortDuration(cue.startTime) }}
27
+ - {{ filters.playerShortDuration(cue.endTime) }}
28
+ </span>
29
+ </v-list-item-action>
30
+ </v-list-item>
31
+ </v-list-item-group>
32
+ </v-list>
33
+ </v-card-text>
34
+ </v-card>
35
+ </template>
36
+
37
+ <script>
38
+ import filters from '../filters'
39
+
40
+ export default {
41
+ props: {
42
+ value: { type: Object, required: true },
43
+ language: { type: String, required: false, default: 'en-US' },
44
+ },
45
+ data() {
46
+ return {
47
+ filters,
48
+ captions: {},
49
+ captionIndex: 0,
50
+ }
51
+ },
52
+ watch: {
53
+ value: {
54
+ deep: true,
55
+ handler(captions) {
56
+ this.captions = captions
57
+ this.captionIndex = this.currentCue(this.captions)
58
+ },
59
+ },
60
+ },
61
+ methods: {
62
+ cueKey(cue) {
63
+ const str =
64
+ cue.language +
65
+ cue.startTime.toString() +
66
+ cue.endTime.toString() +
67
+ cue.text
68
+ return str.split('').reduce(function (a, b) {
69
+ a = (a << 5) - a + b.charCodeAt(0)
70
+ return a & a
71
+ }, 0)
72
+ },
73
+ currentCue(captions) {
74
+ let currentIndex = 0
75
+
76
+ if (captions.activeCues && captions.activeCues.length) {
77
+ for (let i = 0; i < captions.cues.length; i++) {
78
+ const cue = captions.cues[i]
79
+ if (captions.activeCues[0].startTime === cue.startTime) {
80
+ currentIndex = i
81
+ }
82
+ }
83
+ } else {
84
+ // If no active queues then keep the index the same
85
+ return this.captionIndex
86
+ }
87
+
88
+ // If the captions ref and index is available and the list ref is available
89
+ // Auto-scroll the list to the current caption
90
+ if (
91
+ this.$refs.captionItems &&
92
+ this.$refs.captionItems[currentIndex] &&
93
+ this.$refs.captionItems[currentIndex].$el &&
94
+ this.$refs.captionList &&
95
+ this.$refs.captionList.$el
96
+ ) {
97
+ this.$refs.captionList.$el.scrollTop =
98
+ this.$refs.captionItems[currentIndex].$el.offsetTop
99
+ }
100
+
101
+ return currentIndex
102
+ },
103
+ onCueClick(time) {
104
+ this.$emit('click:cue', time)
105
+ },
106
+ },
107
+ mounted() {
108
+ this.captions = this.value
109
+ this.captionIndex = this.currentCue(this.captions)
110
+ },
111
+ }
112
+ </script>
113
+
114
+ <style scoped>
115
+ .captions-list {
116
+ max-height: 10em;
117
+ overflow-y: scroll;
118
+ /* Fade the top/bottom 20% effect. The "red" mask is so the scrollbar doesn't get this effect*/
119
+ mask: linear-gradient(90deg, rgba(255, 0, 0, 0) 98%, rgba(255, 0, 0, 1) 98%),
120
+ linear-gradient(
121
+ 0deg,
122
+ rgba(0, 0, 0, 0) 0%,
123
+ rgba(0, 0, 0, 1) 20%,
124
+ rgba(0, 0, 0, 1) 80%,
125
+ rgba(0, 0, 0, 0) 100%
126
+ );
127
+ }
128
+ </style>