Skip to content

Commit

Permalink
chore(chromecast): add loglevel
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed May 4, 2024
1 parent e2c18c0 commit 46c135d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
24 changes: 9 additions & 15 deletions packages/docs/public/oplayer.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,6 @@
}
}

[data-key='oplayer-plugin-hls-Quality'][role='menuitem'] .css-1i40n7c::before {
content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect width='24' height='24' fill='none'/%3E%3Cpath fill='white' fill-rule='evenodd' d='M13.354 8.75H4a.75.75 0 0 1 0-1.5h9.354a2.751 2.751 0 0 1 5.293 0H20a.75.75 0 0 1 0 1.5h-1.354a2.751 2.751 0 0 1-5.292 0M14.75 8a1.25 1.25 0 1 1 2.5 0a1.25 1.25 0 0 1-2.5 0m-4.103 8.75H20a.75.75 0 0 0 0-1.5h-9.353a2.751 2.751 0 0 0-5.293 0H4a.75.75 0 0 0 0 1.5h1.354a2.751 2.751 0 0 0 5.292 0M6.75 16a1.25 1.25 0 1 1 2.5 0a1.25 1.25 0 0 1-2.5 0' clip-rule='evenodd'/%3E%3C/svg%3E");
width: 1.8rem;
height: 1.8rem;
flex-shrink: 0;
display: block;
margin-right: 5px;
}

[data-ctrl-hidden='false'] video {
filter: brightness(0.85);
}

@media (max-width: 640px) {
[aria-label='Screenshot'] {
display: none !important;
Expand Down Expand Up @@ -203,7 +190,7 @@
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected]/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].12/dist/chromecast.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected].13-chromecast.0/dist/chromecast.min.js"></script>

<script>
var playlistScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/[email protected]/dist/playlist.min.js'
Expand Down Expand Up @@ -328,7 +315,14 @@
ODash({ library: 'https://cdn.dashjs.org/latest/dash.all.min.js' }),
OMpegts({ library: 'https://cdn.jsdelivr.net/npm/mpegts.js/dist/mpegts.min.js' }),
new OAirplay(),
new OChromecast()
new OChromecast({
loggerLevel: 0,
loadRequestBuilder(r) {
r.media.hlsSegmentFormat = 'fmp4'
r.media.hlsVideoSegmentFormat = 'fmp4'
return r
}
})
])
.create()
.on(console.log)
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",
"version": "1.0.13-chromecast.0",
"author": "shiyiya",
"description": "oplayer's plugin",
"homepage": "https://github.com/shiyiya/oplayer",
Expand Down
11 changes: 9 additions & 2 deletions packages/plugins/src/chromecast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export interface ChromeCastOptions {
resumeSavedSession?: boolean | undefined
/** The following flag enables Cast Connect(requires Chrome 87 or higher) */
androidReceiverCompatible?: boolean | undefined
/**
* DEBUG: 0, INFO: 800, WARNING: 900, ERROR: 1000, NONE: 1500
*/
loggerLevel: number
loadRequestBuilder: (request: chrome.cast.media.LoadRequest) => chrome.cast.media.LoadRequest
}

class ChromeCast implements PlayerPlugin {
Expand Down Expand Up @@ -109,11 +114,10 @@ class ChromeCast implements PlayerPlugin {
}

const request = new chrome.cast.media.LoadRequest(mediaInfo)

request.autoplay = this.player.isPlaying
request.currentTime = this.player.currentTime

return request
return this.options?.loadRequestBuilder(request) || request
}

_loadCast() {
Expand All @@ -124,6 +128,9 @@ class ChromeCast implements PlayerPlugin {
window.__onGCastApiAvailable == undefined

if (isAvailable) {
if (typeof this.options?.loggerLevel != 'undefined') {
cast.framework.setLoggerLevel(this.options.loggerLevel)
}
resolve()
} else {
reject(Error('CAST_NOT_AVAILABLE'))
Expand Down

0 comments on commit 46c135d

Please sign in to comment.