Skip to content

Commit

Permalink
try fix chromecast (#125)
Browse files Browse the repository at this point in the history
* Update chromecast.ts

* try fix chromecast
  • Loading branch information
shiyiya authored Mar 31, 2024
1 parent f33c654 commit 489b40d
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 158 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

## Feature

- **Streaming** - support for [hls.js](https://oplayer.vercel.app/plugins/hls), [flv,mpegts](https://oplayer.vercel.app/plugins/mpegts), [webtorrent](https://oplayer.vercel.app/plugins/torrent), [dash.js](https://oplayer.vercel.app/plugins/dash) and any other custom streaming playback
- **Streaming** - support for [hls.js](https://oplayer.vercel.app/hls), [flv,mpegts](https://oplayer.vercel.app/mpegts), [dash.js](https://oplayer.vercel.app/dash), [webtorrent](https://oplayer.vercel.app/torrent) and any other custom streaming playback
- **Fullscreen** - supports native fullscreen with fallback to "full window" modes
- **Shortcuts** - supports keyboard shortcuts
- **Picture-in-Picture** - supports picture-in-picture mode
Expand All @@ -22,9 +22,9 @@
- **Preview thumbnails** - support for displaying preview thumbnails (spirit or [vtt](https://oplayer.vercel.app/plugins/vtt-thumbnails))
- **No frameworks** - written in "vanilla" JavaScript, no dependencies required
- **[Chromecast](https://oplayer.vercel.app/plugins/chromecast)** - cast video to your device
- **[AirPlay](./packages/plugins/)** - cast video to apple device
- **[AirPlay](https://oplayer.vercel.app/plugins/airplay)** - cast video to apple device
- **[Playlist](https://oplayer.vercel.app/plugins/playlist)** - supports playlist list ui
- **[Danmaku](./packages/danmaku/)** - biu biu biu ~
- **[Danmaku](https://oplayer.vercel.app/danmaku)** - biu biu biu ~
- **... and much more!**

## Who use OPlayer?
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@
"@babel/plugin-transform-template-literals": "^7.24.1",
"@changesets/cli": "^2.27.1",
"@rollup/plugin-babel": "^6.0.4",
"@types/node": "^20.11.30",
"@types/node": "^20.12.2",
"@vitejs/plugin-react": "^4.2.1",
"babel-plugin-syntax-trailing-function-commas": "^6.22.0",
"concurrently": "^8.2.2",
"cross-env": "^7.0.3",
"jsdom": "^24.0.0",
"lint-staged": "^15.2.2",
"nx": "^18.1.3",
"nx": "^18.2.1",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"terser": "^5.30.0",
"tslib": "^2.6.2",
"typescript": "^5.4.3",
"vite": "^5.2.6",
"vite": "^5.2.7",
"vite-plugin-banner": "^0.7.1",
"vitest": "^1.4.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"devDependencies": {
"@types/react": "^18.2.73",
"@types/react-dom": "^18.2.22",
"@types/react-dom": "^18.2.23",
"sass": "^1.72.0"
}
}
4 changes: 2 additions & 2 deletions packages/docs/public/ohls.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@
<div id="oplayer"></div>

<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected]/dist/index.ui.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected].2/dist/airplay.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected].2/dist/chromecast.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected].3/dist/airplay.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected].3/dist/chromecast.min.js"></script>

<script>
var hlsScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/hls@latest/dist/index.hls.js'
Expand Down
19 changes: 19 additions & 0 deletions packages/docs/src/pages/plugins/airplay.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Chromecast

```shell
npm i @oplayer/plugins
```

```js
import { AirPlay } from '@oplayer/plugins'

Player.make('#oplayer').use([new AirPlay()]).create()
```

```html
<script src="https://cdn.jsdelivr.net/npm/@oplayer/plugins@latest/dist/airplay.min.js"></script>

<script>
Player.make('#oplayer').use([new OAirPlay()]).create()
</script>
```
2 changes: 1 addition & 1 deletion packages/plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@oplayer/ui": "workspace:*",
"@types/chromecast-caf-sender": "^1.0.9",
"chokidar": "^3.6.0",
"glob": "^10.3.10",
"glob": "^10.3.12",
"m3u8-parser": "^7.1.0",
"vite-plugin-css-injected-by-js": "^3.5.0"
}
Expand Down
8 changes: 4 additions & 4 deletions packages/plugins/src/chromecast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ class ChromeCast implements PlayerPlugin {
try {
await this._loadCast()

const State = window.cast.framework.CastState
if (this.cast.getCastState() === State.NO_DEVICES_AVAILABLE) {
throw new Error(`Chrome Cast Error Code: ${State.NO_DEVICES_AVAILABLE}`)
}
// const State = window.cast.framework.CastState
// if (this.cast.getCastState() === State.NO_DEVICES_AVAILABLE) {
// throw new Error(`Chrome Cast Error Code: ${State.NO_DEVICES_AVAILABLE}`)
// }

const errorCode = await this.__requestChromeCast()
if (errorCode) {
Expand Down
Loading

0 comments on commit 489b40d

Please sign in to comment.