-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: update implementation for vue 3 (#113)
- Loading branch information
Showing
11 changed files
with
341 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>stream-vue</title> | ||
</head> | ||
|
||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "stream-vue-playground", | ||
"type": "module", | ||
"private": true, | ||
"scripts": { | ||
"dev": "vite dev" | ||
}, | ||
"dependencies": { | ||
"@vitejs/plugin-vue": "latest", | ||
"@vueuse/core": "^10.9.0", | ||
"stream-vue": "latest", | ||
"vite": "latest", | ||
"vue": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<script setup lang="ts"> | ||
// https://github.com/cloudflare/stream-react/blob/master/example/src/index.tsx | ||
import { VideoStream } from 'stream-vue' | ||
import { ref } from 'vue' | ||
import { useLocalStorage } from '@vueuse/core' | ||
const videostream = ref<InstanceType<typeof VideoStream> | null>(null) | ||
function setTime() { | ||
if (videostream.value?.streamRef) { | ||
videostream.value.streamRef.currentTime = 30 | ||
} | ||
} | ||
function play() { | ||
videostream.value?.streamRef?.play() | ||
} | ||
const configuration = useLocalStorage('stream-state', { | ||
autoplay: [true, { type: 'checkbox' }], | ||
muted: [true, { type: 'checkbox' }], | ||
loop: [true, { type: 'checkbox' }], | ||
controls: [true, { type: 'checkbox' }], | ||
responsive: [true, { type: 'checkbox' }], | ||
volume: [1, { type: 'range', min: 0, max: 1, step: 0.01 }], | ||
playbackRate: [1, { type: 'range', min: 0.25, max: 2, step: 0.25 }], | ||
} as const) | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<VideoStream | ||
ref="videostream" | ||
src="4bcf13d23290043d9efb344b56200ebd" | ||
:muted="configuration.muted[0]" | ||
:loop="configuration.loop[0]" | ||
:controls="configuration.controls[0]" | ||
:responsive="configuration.responsive[0]" | ||
:autoplay="configuration.autoplay[0]" | ||
:volume="configuration.volume[0]" | ||
:playback-rate="configuration.playbackRate[0]" | ||
/> | ||
<div> | ||
<label v-for="item, key in configuration" :key="key" :style="{ display: 'inline-block', border: '1px solid', padding: '4px 8px' }"> | ||
{{ key }} | ||
<input v-model="item[0]" v-bind="item[1]"> | ||
</label> | ||
</div> | ||
<button @click="setTime"> | ||
seek to 30s | ||
</button> | ||
<button @click="play"> | ||
play | ||
</button> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { createApp } from 'vue' | ||
import App from './App.vue' | ||
|
||
createApp(App).mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { defineConfig } from 'vite' | ||
import vue from '@vitejs/plugin-vue' | ||
|
||
export default defineConfig({ | ||
plugins: [vue()], | ||
}) |
Oops, something went wrong.