Skip to content

Commit

Permalink
fix(chromecast): err handler
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed Mar 27, 2024
1 parent 47e93d3 commit 270e87b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
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-beta.0",
"version": "1.0.12-beta.1",
"author": "shiyiya",
"description": "oplayer's plugin",
"homepage": "https://github.com/shiyiya/oplayer",
Expand Down
17 changes: 8 additions & 9 deletions packages/plugins/src/chromecast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,15 @@ class ChromeCast implements PlayerPlugin {
throw new Error(`Chrome Cast Error Code: ${errorCode}`)
}
} catch (error) {
const msg =
error instanceof chrome.cast.Error
? `${error.code} - ${error.description} \n ${error.details}`
: (error as Error).message
let msg = 'UNKNOWN ERROR'

this._notice(msg)
if (error instanceof Error) {
msg = error.message
} else if (!!chrome.cast && error instanceof chrome.cast.Error) {
msg = `${error.code} - ${error.description} \n ${error.details}`
}

this.player.emit('notice', { text: msg })
}
}

Expand All @@ -170,10 +173,6 @@ class ChromeCast implements PlayerPlugin {
onClick: () => this.start()
})
}

_notice(message: string) {
this.player.context.ui?.notice(message)
}
}

export default ChromeCast

0 comments on commit 270e87b

Please sign in to comment.