UNPKG

@7sage/vidstack

Version:

UI component library for building high-quality, accessible video and audio experiences on the web.

46 lines (43 loc) 1.57 kB
import { listenEvent } from './vidstack-BGSTndAW.js'; function getCastFrameworkURL() { return "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"; } function hasLoadedCastFramework() { return !!window.cast?.framework; } function isCastAvailable() { return !!window.chrome?.cast?.isAvailable; } function isCastConnected() { return getCastContext().getCastState() === cast.framework.CastState.CONNECTED; } function getCastContext() { return window.cast.framework.CastContext.getInstance(); } function getCastSession() { return getCastContext().getCurrentSession(); } function getCastSessionMedia() { return getCastSession()?.getSessionObj().media[0]; } function hasActiveCastSession(src) { const contentId = getCastSessionMedia()?.media.contentId; return contentId === src?.src; } function getDefaultCastOptions() { return { language: "en-US", autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED, receiverApplicationId: chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID, resumeSavedSession: true, androidReceiverCompatible: true }; } function getCastErrorMessage(code) { const defaultMessage = `Google Cast Error Code: ${code}`; return defaultMessage; } function listenCastContextEvent(type, handler) { return listenEvent(getCastContext(), type, handler); } export { getCastContext, getCastErrorMessage, getCastFrameworkURL, getCastSession, getCastSessionMedia, getDefaultCastOptions, hasActiveCastSession, hasLoadedCastFramework, isCastAvailable, isCastConnected, listenCastContextEvent };