无法在initializeCastApi读取未定义的属性“ SessionRequest”

时间:2019-03-27 15:20:24

标签: google-chrome google-chrome-extension google-chrome-app chromecast

我的代码给我错误

Cannot read property 'SessionRequest' of undefined
    at initializeCastApi

我不知道发生了什么事。 本质上,当我单击复选框时,会发出请求,并且客户应用程序将显示在Chrome Cast中。我什至无法开始会议。

<link rel="stylesheet"
    href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script type="text/javascript"
    src="//www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>
    <script src="//www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
<script type="text/javascript"

<script type="text/javascript">
    var applicationID = 'F69D8642';
    var namespace = 'urn:x-cast:com.website';
    var session = null;

    /*

     /** Disable right click on Main screen
     document.onmousedown=disableclick;
     function disableclick(event)
     {
     if(event.button==2)
     {
     return false;
     }
     }


     <body oncontextmenu="return false">
     */

     /**
     **************************************************************************************
     ********                    Call initialization for Cast                      ********
     **************************************************************************************
     */
    if (!chrome.cast || !chrome.cast.isAvailable) {
        setTimeout(initializeCastApi, 1000);
    }

    /**
     **************************************************************************************
     ********                            initialization                            ********
     **************************************************************************************
     */
    function initializeCastApi() {
        console.log("initializeCastApi : " + applicationID);
        var sessionRequest = new chrome.cast.SessionRequest(applicationID);
        var apiConfig = new chrome.cast.ApiConfig(sessionRequest,
                sessionListener, receiverListener);

        chrome.cast.initialize(apiConfig, onInitSuccess, onError);
    };

0 个答案:

没有答案