Skip to content

Commit

Permalink
feat(ui): add keyboard.
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed Mar 11, 2024
1 parent 1ee86e4 commit 4bc77ba
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
35 changes: 35 additions & 0 deletions packages/docs/public/ios_debug.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="referrer" content="no-referrer" />
<title>Start streaming now using OPlayer - Free HTML5 Player</title>
</head>
<body style="margin: 0">
<div id="oplayer" style="width: 100vw; height: 100vh"></div>

<script src="https://cdn.jsdelivr.net/npm/@oplayer/core@latest/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/ui@latest/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/hls@latest/dist/index.hls.js"></script>
<script src=" https://cdn.jsdelivr.net/npm/vconsole@latest/dist/vconsole.min.js"></script>

<script>
const search = new URLSearchParams(document.location.search)
const src = decodeURIComponent(search.get('src'))

var vConsole = new window.VConsole()

var player = OPlayer.make('#oplayer', {
source: {
src: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8'
// poster: 'http://5b0988e595225.cdn.sohucs.com/images/20190420/da316f8038b242c4b34f6db18b0418d4.gif'
}
})
.use([OUI(), OHls({ forceHLS: search.get('fh') })])
.create()
.on(console.log)
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion packages/docs/src/pages/ui.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,5 @@ const ui = OUI({
## Events

```ts
type UIEventName = 'controllervisibilitychange' | 'backward' | 'previous' | 'next'
type UIEventName = 'controlsshown' | 'controlshidden' | 'backward' | 'previous' | 'next'
```
7 changes: 5 additions & 2 deletions packages/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

## UnRelease

- any px -> rem
- ErrorBuilder custom params
- any px -> rem.
- ErrorBuilder custom params.
- add keyboard.
- k: play | pause
- m: mute | unmute

## [1.2.35]

Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const render = (it: UIInterface) => {
}
addClass(player.$root, controllerHidden)
player.$root.setAttribute(DATA_CONTROLLER_HIDDEN, 'true')
player.emit('controllervisibilitychange', false)
player.emit('controlshidden', false)
}

const { callee: debounceHideCtrl, clear: cancelHideCtrl } = debounce(hideCtrl, CTRL_HIDE_DELAY)
Expand All @@ -45,7 +45,7 @@ const render = (it: UIInterface) => {
if (hasClass(player.$root, controllerHidden)) {
removeClass(player.$root, controllerHidden)
player.$root.setAttribute(DATA_CONTROLLER_HIDDEN, 'false')
player.emit('controllervisibilitychange', true)
player.emit('controlsshown', true)
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/ui/src/functions/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const KEY_FN: Record<string, (player: Player) => void> = {
},

' ': (player: Player) => player.togglePlay(),
k: (player: Player) => player.togglePlay(),

Escape: (player: Player) => {
if (player.isFullScreen) {
Expand All @@ -55,7 +56,9 @@ const KEY_FN: Record<string, (player: Player) => void> = {

w: (player: Player) => player.emit('fullscreenchange', { isWeb: true }),

s: screenShot
s: screenShot,

m: (player: Player) => (player.isMuted ? player.unmute() : player.mute())
}

export default function (it: UIInterface) {
Expand Down

0 comments on commit 4bc77ba

Please sign in to comment.