-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1332fe
commit a0d7433
Showing
30 changed files
with
656 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@headlessplayback/rotatable-plugin": minor | ||
--- | ||
|
||
Release rotatable plugin 💞 |
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
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,109 @@ | ||
import { usePlayback } from "@headlessplayback/react" | ||
import { rotatablePlaybackPlugin } from "@headlessplayback/rotatable-plugin" | ||
import React, { useEffect } from "react" | ||
|
||
const id = "rotatable" | ||
|
||
usePlayback.use(rotatablePlaybackPlugin) | ||
|
||
function CurrentTime() { | ||
const playback = usePlayback({ | ||
id, | ||
}) | ||
|
||
return <p>Current time: {playback.playbackState.currentTime}</p> | ||
} | ||
|
||
const Duration = React.memo(() => { | ||
const { playbackState } = usePlayback({ | ||
id, | ||
}) | ||
|
||
return <p>Duration: {playbackState.duration}</p> | ||
}) | ||
|
||
function Rotatable() { | ||
const { activate, playbackActions, playbackState } = usePlayback({ | ||
id, | ||
}) | ||
const videoContainerRef = React.useRef<HTMLDivElement>(null) | ||
|
||
useEffect(() => { | ||
// Activate when playback element is accessible from the DOM | ||
activate() | ||
|
||
playbackActions.createRotatablePlayback({ | ||
container: videoContainerRef.current as HTMLDivElement, | ||
}) | ||
}, []) | ||
|
||
function jumpNext5s() { | ||
// Core actions and state are always available | ||
playbackActions.setCurrentTime(playbackState.currentTime + 5) | ||
} | ||
|
||
function jumpPrev5s() { | ||
playbackActions.setCurrentTime(playbackState.currentTime - 5) | ||
} | ||
|
||
function togglePlayback() { | ||
playbackActions.setPaused(!playbackState.paused) | ||
} | ||
|
||
function rotate() { | ||
playbackActions.rotate() | ||
} | ||
|
||
return ( | ||
<> | ||
<div | ||
ref={videoContainerRef} | ||
className="border-fuchsia border-1 grid h-[400px] w-[600px] place-items-center" | ||
> | ||
<video | ||
style={{ | ||
width: playbackState.width, | ||
height: playbackState.height, | ||
}} | ||
src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" | ||
id={id} | ||
></video> | ||
</div> | ||
|
||
<CurrentTime /> | ||
<Duration /> | ||
|
||
<div className="flex space-x-1 "> | ||
<button | ||
className="rounded-md bg-violet-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-violet-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-violet-600" | ||
onClick={jumpPrev5s} | ||
> | ||
Prev 5s | ||
</button> | ||
|
||
<button | ||
className="rounded-md bg-violet-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-violet-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-violet-600" | ||
onClick={togglePlayback} | ||
> | ||
{playbackState.paused ? "Play" : "Pause"} | ||
</button> | ||
|
||
<button | ||
className="rounded-md bg-violet-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-violet-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-violet-600" | ||
onClick={jumpNext5s} | ||
> | ||
Next 5s | ||
</button> | ||
|
||
<button | ||
className="rounded-md bg-violet-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-violet-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-violet-600" | ||
onClick={rotate} | ||
> | ||
Rotate | ||
</button> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
export default Rotatable |
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
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,86 @@ | ||
<script lang="ts" setup> | ||
import { usePlayback } from "@headlessplayback/vue" | ||
import { rotatablePlaybackPlugin } from "@headlessplayback/rotatable-plugin" | ||
import { onMounted, ref } from "vue" | ||
usePlayback.use(rotatablePlaybackPlugin) | ||
const id = "rotatable" | ||
const videoRef = ref<HTMLElement | null>(null) | ||
const { activate, playbackActions, playbackState } = usePlayback({ | ||
id, | ||
}) | ||
onMounted(() => { | ||
// Activate when playback element is accessible from the DOM | ||
activate() | ||
playbackActions.createRotatablePlayback({ | ||
container: videoRef.value as HTMLElement, | ||
}) | ||
}) | ||
const jumpTo = (time: number) => { | ||
// Core actions and state are always available | ||
playbackActions.setCurrentTime(time) | ||
} | ||
const togglePlayback = () => { | ||
playbackActions.setPaused(!playbackState.paused) | ||
} | ||
const rotate = () => { | ||
playbackActions.rotate() | ||
} | ||
</script> | ||
|
||
<template> | ||
<div | ||
ref="videoRef" | ||
className="border-fuchsia border-1 grid h-[400px] w-[600px] place-items-center" | ||
> | ||
<video | ||
:style="{ | ||
width: `${playbackState.width}px`, | ||
height: `${playbackState.height}px`, | ||
}" | ||
src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" | ||
:id="id" | ||
> | ||
<track kind="captions" /> | ||
</video> | ||
</div> | ||
|
||
<p>Current time: {{ playbackState.currentTime }}</p> | ||
|
||
<p>Duration: {{ playbackState.duration }}</p> | ||
<div class="flex space-x-1"> | ||
<button | ||
class="rounded-md bg-violet-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-violet-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-violet-600" | ||
@click="jumpTo(playbackState.currentTime - 5)" | ||
> | ||
Prev 5s | ||
</button> | ||
|
||
<button | ||
class="rounded-md bg-violet-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-violet-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-violet-600" | ||
@click="togglePlayback" | ||
> | ||
{{ playbackState.paused ? "Play" : "Pause" }} | ||
</button> | ||
|
||
<button | ||
class="rounded-md bg-violet-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-violet-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-violet-600" | ||
@click="jumpTo(playbackState.currentTime + 5)" | ||
> | ||
Next 5s | ||
</button> | ||
|
||
<button | ||
class="rounded-md bg-violet-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-violet-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-violet-600" | ||
@click="rotate" | ||
> | ||
Rotate | ||
</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
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
Oops, something went wrong.