Skip to content

Commit

Permalink
fix failed to chrome casting (#133)
Browse files Browse the repository at this point in the history
* fix failed to chrome casting
  • Loading branch information
shiyiya authored Aug 17, 2024
1 parent 4bdf342 commit 2c9d7eb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout code repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: load cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v4
with:
version: latest
run_install: true
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/compressed-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v4
with:
version: latest
run_install: false
Expand All @@ -38,7 +38,7 @@ jobs:
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import { Playlist, Chromecast, AirPlay } from '@oplayer/plugins'
hls({ forceHLS: true }),
dash(),
mpegts(),
!isMobile && danmaku({ enable: true, fontSize: 0.75, displaySender: false }),
danmaku({ enable: !isMobile, fontSize: 0.75, displaySender: false }),
new Playlist({
initialIndex: 0,
autoNext: true,
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.13",
"version": "1.0.14-beta.0",
"author": "shiyiya",
"description": "oplayer's plugin",
"homepage": "https://github.com/shiyiya/oplayer",
Expand Down
13 changes: 9 additions & 4 deletions packages/plugins/src/chromecast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface ChromeCastOptions {
androidReceiverCompatible?: boolean | undefined
}

class ChromeCast implements PlayerPlugin {
class Chromecast implements PlayerPlugin {
readonly name = 'oplayer-plugin-chromecast'
readonly version = __VERSION__

Expand Down Expand Up @@ -87,7 +87,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')

const mediaInfo = new chrome.cast.media.MediaInfo(
source.src,
this.player.loader?.key == 'hls' ? 'application/x-mpegurl' : 'video/mp4'
)
;(mediaInfo as any).contentUrl = source.src
mediaInfo.streamType = isLive ? chrome.cast.media.StreamType.LIVE : chrome.cast.media.StreamType.BUFFERED

const metadata = new chrome.cast.media.GenericMediaMetadata()
Expand Down Expand Up @@ -143,12 +148,12 @@ class ChromeCast implements PlayerPlugin {
const { menu, icons } = this.player.context.ui

menu?.register({
name: 'ChromeCast',
name: 'Chromecast',
position: 'top',
icon: icons.chromecast || ICON,
onClick: () => this.start()
})
}
}

export default ChromeCast
export default Chromecast

0 comments on commit 2c9d7eb

Please sign in to comment.