-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
67 lines (59 loc) · 2.19 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<head>
<meta charset="utf-8"/>
<link href="http://vjs.zencdn.net/5.8.8/video-js.css" rel="stylesheet">
<!-- If you'd like to support IE8 -->
<script src="http://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script>
<script src="http://vjs.zencdn.net/5.8.8/video.js"></script>
<script src="https://unpkg.com/vue"></script>
</head>
<body>
<div id="app">
<ul>
<li v-for="name in names">
<div @click="play(name)" style="cursor: pointer;">{{ name }}</div>
</li>
</ul>
<video v-if="currentPlayName" id="my-video" class="video-js" controls preload="auto" width="640" height="264"
data-setup="{}">
<source :src="currentPlayName" type='video/mp4'>
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a web browser that
<a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
</p>
</video>
<button v-on:click="refresh">refresh</button>
</div>
<script>
const RET_CODE_OK = 100;
var app = new Vue({
el: '#app',
data: {
names: ["2015812051502-cki2y0.mp4","2years-ie.mp4"],
currentPlayName: null
},
methods: {
play: function (name) {
this.currentPlayName = null;
this.$nextTick(function () {
console.log("start to play video " + name);
this.currentPlayName = name;
}.bind(this))
},
refresh: function () {
//The `fetch` method bellow needs the chrome browser support
fetch("/cmd-refresh").then(function (response) {
var reader = response.body.getReader();
reader.read().then(function processText({ done, value }) {
if (value && value[0]) {
var retCode = value[0];
if (retCode == RET_CODE_OK) {
window.location.reload();
}
}
});
});
}
}
})
</script>
</body>