From 9daa14e32d50e79a4f79bd6c9d8a0c5aff33959f Mon Sep 17 00:00:00 2001 From: Harvey Zack Date: Tue, 16 Apr 2024 10:00:47 +0800 Subject: [PATCH] Update index.js --- packages/artplayer-plugin-chromecast/src/index.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/artplayer-plugin-chromecast/src/index.js b/packages/artplayer-plugin-chromecast/src/index.js index c8499a985..52b240746 100644 --- a/packages/artplayer-plugin-chromecast/src/index.js +++ b/packages/artplayer-plugin-chromecast/src/index.js @@ -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'; window['__onGCastApiAvailable'] = function (isAvailable) { - artplayerPluginChromecast.isAvailable = isAvailable; if (isAvailable) { cast.framework.CastContext.getInstance().setOptions({ receiverApplicationId: chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID, @@ -42,7 +41,9 @@ export default function artplayerPluginChromecast(option) { }; return async (art) => { - await loadScript(option.sdk || DEFAULT_SDK); + if (!window.chrome || !window.chrome.cast) { + await loadScript(option.sdk || DEFAULT_SDK); + } function castVideo(session) { const url = option.url || art.option.url; @@ -66,11 +67,6 @@ export default function artplayerPluginChromecast(option) { tooltip: 'Chromecast', html: `${option.icon || DEFAULT_ICON}`, click() { - if (!artplayerPluginChromecast.isAvailable) { - art.notice.show = 'Cast API is not available'; - return; - } - const castSession = cast.framework.CastContext.getInstance().getCurrentSession(); if (castSession) {