add speed setter and option for display controller or not
This commit is contained in:
14
src/App.html
14
src/App.html
@@ -1,14 +0,0 @@
|
|||||||
<Player {events} />
|
|
||||||
|
|
||||||
<style>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import Player from './Player.html';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
Player,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
{#if showController}
|
||||||
<div class="rr-controller">
|
<div class="rr-controller">
|
||||||
<div class="rr-timeline">
|
<div class="rr-timeline">
|
||||||
<span class="rr-timeline__time">{formatTime(currentTime)}</span>
|
<span class="rr-timeline__time">{formatTime(currentTime)}</span>
|
||||||
@@ -12,10 +13,11 @@
|
|||||||
{isPlaying ? 'pause' : 'play'}
|
{isPlaying ? 'pause' : 'play'}
|
||||||
</button>
|
</button>
|
||||||
{#each [1, 2, 4, 8] as s}
|
{#each [1, 2, 4, 8] as s}
|
||||||
<button class:active="s === speed" on:click="set({ speed: s })">{s}x</button>
|
<button class:active="s === speed" on:click="setSpeed(s)">{s}x</button>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { formatTime } from './utils.js';
|
import { formatTime } from './utils.js';
|
||||||
@@ -69,8 +71,8 @@
|
|||||||
requestAnimationFrame(update);
|
requestAnimationFrame(update);
|
||||||
},
|
},
|
||||||
play() {
|
play() {
|
||||||
const { replayer } = this.get();
|
const { replayer, currentTime } = this.get();
|
||||||
// replayer.play();
|
replayer.play(currentTime);
|
||||||
this.loopTimer();
|
this.loopTimer();
|
||||||
},
|
},
|
||||||
pause() {
|
pause() {
|
||||||
@@ -86,6 +88,11 @@
|
|||||||
this.play();
|
this.play();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
setSpeed(speed) {
|
||||||
|
const { replayer } = this.get();
|
||||||
|
replayer.setConfig({ speed });
|
||||||
|
this.set({ speed });
|
||||||
|
},
|
||||||
},
|
},
|
||||||
onupdate({ changed, current, previous }) {
|
onupdate({ changed, current, previous }) {
|
||||||
if (current.replayer && !previous) {
|
if (current.replayer && !previous) {
|
||||||
@@ -94,6 +101,12 @@
|
|||||||
this.play();
|
this.play();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
ondestroy() {
|
||||||
|
const { isPlaying } = this.get();
|
||||||
|
if (isPlaying) {
|
||||||
|
this.pause();
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="rr-player">
|
<div class="rr-player">
|
||||||
<div class="rr-player__frame" ref:frame { style }></div>
|
<div class="rr-player__frame" ref:frame { style }></div>
|
||||||
{#if replayer}
|
{#if replayer}
|
||||||
<Controller { replayer } />
|
<Controller { replayer } {showController} />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
showController: true,
|
||||||
width: 1024,
|
width: 1024,
|
||||||
height: 576,
|
height: 576,
|
||||||
events: [],
|
events: [],
|
||||||
|
|||||||
15
src/main.js
15
src/main.js
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user