Skip to content

Commit

Permalink
update airplay example
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed Mar 28, 2024
1 parent 8825e10 commit 72a0b3a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
20 changes: 6 additions & 14 deletions packages/docs/public/ohls.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@

<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/[email protected]/dist/airplay.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected]/dist/chromecast.min.js"></script>

<script>
var hlsScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/hls@latest/dist/index.hls.js'
Expand All @@ -221,7 +223,6 @@
var dashScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/dash@latest/dist/index.min.js'

var playlistScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/plugins@latest/dist/playlist.min.js'
var chromecastScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/plugins@latest/dist/chromecast.min.js'
var danmakuScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/danmaku@latest/dist/index.min.js'

var query = document.location.search.substring(1)
Expand Down Expand Up @@ -326,23 +327,14 @@
loop: `<svg viewBox="0 0 256 256"><rect width="256" height="256" fill="none" /><path fill="white" d="M252 128a60 60 0 0 1-102.43 42.43l-.49-.53l-59.86-67.59a36 36 0 1 0 0 51.38l3.08-3.48a12 12 0 1 1 18 15.91l-3.35 3.78l-.49.53a60 60 0 1 1 0-84.86l.49.53l59.86 67.59a36 36 0 1 0 0-51.38l-3.08 3.48a12 12 0 1 1-18-15.91l3.35-3.78l.49-.53A60 60 0 0 1 252 128" /></svg>`,
loadingIndicator: `<svg width="3em" height="3em" viewBox="0 0 24 24"><rect width="24" height="24" fill="none" /><path fill="white" d="M12 2A10 10 0 1 0 22 12A10 10 0 0 0 12 2Zm0 18a8 8 0 1 1 8-8A8 8 0 0 1 12 20Z" opacity="0.5" /><path fill="white" d="M20 12h2A10 10 0 0 0 12 2V4A8 8 0 0 1 20 12Z"><animateTransform attributeName="transform" dur="0.9s" from="0 12 12" repeatCount="indefinite" to="360 12 12" type="rotate" /></svg>`
}
})
}),
new OAirplay(),
new OChromecast()
])
.create()
.on(console.log)

var deps = [
[
chromecastScriptCdn,
() => {
if (OChromecast.constructor == Object) {
player.applyPlugin(OChromecast)
} else {
player.applyPlugin(new OChromecast())
}
}
]
]
var deps = []

if (/m3u8(#|\?|$)/.test(src) || playlist.some((it) => /m3u8(#|\?|$)/.test(it.src))) {
deps.push([
Expand Down
5 changes: 3 additions & 2 deletions packages/docs/src/pages/preview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dash from '@oplayer/dash'
import mpegts from '@oplayer/mpegts'
import ui from '@oplayer/ui'
import danmaku from '@oplayer/danmaku'
import { PlaylistPlugin, Chromecast } from '@oplayer/plugins'
import { PlaylistPlugin, Chromecast, AirPlay } from '@oplayer/plugins'

<div className="nx-rounded-sm nx-overflow-hidden" style={{ maxWidth: '1024px', margin: '1.25rem auto' }}>
<Player
Expand Down Expand Up @@ -118,7 +118,8 @@ import { PlaylistPlugin, Chromecast } from '@oplayer/plugins'
}
]
}),
new Chromecast()
new Chromecast(),
new AirPlay()
].filter((it) => it?.apply)}

/>
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/airplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AirPlay implements PlayerPlugin {
return !!(globalThis as any).WebKitPlaybackTargetAvailabilityEvent
}

async start() {
start() {
const $media: any = this.player.$video
if ($media.webkitShowPlaybackTargetPicker) {
$media.webkitShowPlaybackTargetPicker()
Expand Down

0 comments on commit 72a0b3a

Please sign in to comment.