Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed Mar 25, 2024
1 parent 37ccfda commit 5bb2a68
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 16 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/compressed-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: setup node.js
uses: actions/setup-node@v3
with:
node-version: 20.x

- name: Install pnpm
uses: pnpm/[email protected]
with:
Expand All @@ -32,6 +37,7 @@ jobs:
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
Expand All @@ -44,4 +50,4 @@ jobs:
with:
build-script: 'build:packs'
repo-token: '${{ secrets.GIT_HUB_TOKEN }}'
pattern: './packages/*/{dist,compiled}/**/*.{js,d.ts}'
pattern: './packages/*/{dist,compiled}/**/*.{js}'
13 changes: 10 additions & 3 deletions packages/docs/public/ohls.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@
<script>
var hlsScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/hls@latest/dist/index.hls.js'
var danmakuScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/danmaku@latest/dist/index.min.js'
var playlistScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/plugins@latest/dist/playlist.min.js'
var playlistScriptCdn =
'https://cdn.jsdelivr.net/npm/@oplayer/[email protected]/dist/playlist.min.js'
var chromecastScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/plugins@latest/dist/chromecast.min.js'

var query = document.location.search.substring(1)
Expand Down Expand Up @@ -264,7 +265,11 @@
}

var player = OPlayer.make('#oplayer', {
source: { src: !playlist.length ? src : undefined, poster, title: title || 'Free HTML5 Player' },
source: {
src: /m3u8(#|\?|$)/.test(src) || /.mpd(#|\?|$)/i.test(src) ? undefined : src,
poster,
title: title || 'Free HTML5 Player'
},
playbackRate: localStorage.getItem('@oplayer/UserPreferences/speed') || 1,
volume: localStorage.getItem('@oplayer/UserPreferences/volume') || 1
})
Expand Down Expand Up @@ -326,7 +331,7 @@
[
chromecastScriptCdn,
() => {
player.applyPlugin(OChromecast)
player.applyPlugin(new OChromecast())
}
]
]
Expand Down Expand Up @@ -372,6 +377,8 @@
})

function bootstrap() {
if (!player.options.source.src && src) player.changeSource({ src, poster })

if (danmaku) {
loadScripts([danmakuScriptCdn]).then((p) => {
player.applyPlugin(ODanmaku({ source: danmaku }))
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oplayer/plugins",
"version": "1.0.12.alpha.0",
"version": "1.0.12.beta.0",
"author": "shiyiya",
"description": "oplayer's plugin",
"homepage": "https://github.com/shiyiya/oplayer",
Expand Down
16 changes: 6 additions & 10 deletions packages/plugins/src/chromecast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,12 @@ class ChromeCast implements PlayerPlugin {
__buildRequest() {
const { source, isLive } = this.player.options
const mediaInfo = new chrome.cast.media.MediaInfo(source.src, source.type || 'video/mp4')
mediaInfo.streamType = isLive ? chrome.cast.media.StreamType.LIVE : chrome.cast.media.StreamType.BUFFERED

mediaInfo.metadata = new chrome.cast.media.GenericMediaMetadata()
mediaInfo.metadata.title = source.title
mediaInfo.metadata.images = [{ url: source.poster }]

if (isLive) {
mediaInfo.streamType = chrome.cast.media.StreamType.LIVE
} else {
mediaInfo.streamType = chrome.cast.media.StreamType.BUFFERED
}
const metadata = new chrome.cast.media.GenericMediaMetadata()
if (source.title) metadata.title = source.title
if (source.poster) metadata.images = [{ url: source.poster, height: null, width: null }]
mediaInfo.metadata = metadata

const subtitles = this.player.context.ui?.config.subtitle?.source as any[]
mediaInfo.tracks = subtitles.map((sub, id) => {
Expand All @@ -103,7 +99,7 @@ class ChromeCast implements PlayerPlugin {
track.name = sub.name
track.trackContentId = sub.src
track.trackContentType = sub.type || 'text/vtt' //TODO: url match
// track.language = sub.language
track.language = sub.language || sub.name
track.subtype = chrome.cast.media.TextTrackType.CAPTIONS

return track
Expand Down
3 changes: 2 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const globals = {
'hls.js': 'Hls',
'hls.js/dist/hls.min.js': 'Hls',
'mpegts.js/dist/mpegts.js': 'mpegts',
'webtorrent/dist/webtorrent.min.js': 'WebTorrent'
'webtorrent/dist/webtorrent.min.js': 'WebTorrent',
'webtorrent/webtorrent.min.js': 'WebTorrent'
}

const babelPlugins = [
Expand Down

0 comments on commit 5bb2a68

Please sign in to comment.