mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 00:31:20 -08:00
Update index.js
This commit is contained in:
1 parent
3ca3a3b781
commit
9daa14e32d
1 file changed
+3
-7
@@ -32,7 +32,6 @@ export default function artplayerPluginChromecast(option) {
|
|||||||
const DEFAULT_SDK = 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1';
|
const DEFAULT_SDK = 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1';
|
||||||
|
|
||||||
window['__onGCastApiAvailable'] = function (isAvailable) {
|
window['__onGCastApiAvailable'] = function (isAvailable) {
|
||||||
artplayerPluginChromecast.isAvailable = isAvailable;
|
|
||||||
if (isAvailable) {
|
if (isAvailable) {
|
||||||
cast.framework.CastContext.getInstance().setOptions({
|
cast.framework.CastContext.getInstance().setOptions({
|
||||||
receiverApplicationId: chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,
|
receiverApplicationId: chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,
|
||||||
@@ -42,7 +41,9 @@ export default function artplayerPluginChromecast(option) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return async (art) => {
|
return async (art) => {
|
||||||
await loadScript(option.sdk || DEFAULT_SDK);
|
if (!window.chrome || !window.chrome.cast) {
|
||||||
|
await loadScript(option.sdk || DEFAULT_SDK);
|
||||||
|
}
|
||||||
|
|
||||||
function castVideo(session) {
|
function castVideo(session) {
|
||||||
const url = option.url || art.option.url;
|
const url = option.url || art.option.url;
|
||||||
@@ -66,11 +67,6 @@ export default function artplayerPluginChromecast(option) {
|
|||||||
tooltip: 'Chromecast',
|
tooltip: 'Chromecast',
|
||||||
html: `<i class="art-icon art-icon-cast">${option.icon || DEFAULT_ICON}</i>`,
|
html: `<i class="art-icon art-icon-cast">${option.icon || DEFAULT_ICON}</i>`,
|
||||||
click() {
|
click() {
|
||||||
if (!artplayerPluginChromecast.isAvailable) {
|
|
||||||
art.notice.show = 'Cast API is not available';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const castSession = cast.framework.CastContext.getInstance().getCurrentSession();
|
const castSession = cast.framework.CastContext.getInstance().getCurrentSession();
|
||||||
|
|
||||||
if (castSession) {
|
if (castSession) {
|
||||||
|
|||||||
Reference in new issue
Block a user