Chromecast Launch,DIAL参数是什么?我不是在运行我的应用程序,而不是一些注册标准?

时间:2014-01-03 06:19:47

标签: google-chrome chromecast

以下代码显示了我网络上可用的chromecast设备的正确列表。但是当我点击链接时,应用程序永远不会启动。有一些我很困惑的事情可能与这个问题有关,也可能没有:

  1. 如果我正在制作自己的自定义应用程序,DIAL参数是什么,为什么我必须通过它们?我不想为DIAL标准编写应用程序......这是我的应用程序。
  2. 再次与DIAL参数相关,如果我搜索除“YouTube”(DIAL参数)以外的任何其他查询的设备,则列表始终显示为空白。我想我不应该关心,只要设备被列出......但是再次......应用程序将无法启动。
  3. 应该注意的是,我的发件人应用是镀铬网页。

    我对我的“appid”在启动参数中的位置感到有点困惑,'

        <html data-cast-api-enabled="true">
        <body>
        hi!<BR/>
    
        <script>
        var cast_api, cv_activity;
    
        if (window.cast && window.cast.isAvailable) {
          // Cast is known to be available
          initializeApi();
    
        } else {
          // Wait for API to post a message to us
          window.addEventListener("message", function(event) {
            if (event.source == window && event.data && 
                event.data.source == "CastApi" &&
                event.data.event == "Hello")
            {
                  //document.write("Initialize via message.<br/>");
                initializeApi();
                  //document.write("Api initialized via message.");
            };
          });
        };
    
        initializeApi = function() {
          cast_api = new cast.Api();
          cast_api.addReceiverListener("YouTube", onReceiverList);
        };
    
        var g_list;
        onReceiverList = function(list) {
            g_list = list;
        // If the list is non-empty, show a widget with
        // the friendly names of receivers.
        // When a receiver is picked, invoke doLaunch with the receiver.
        document.write("Receivers: "+list.length+"<br/>");
        var t;
        for(t=0;t<list.length;t++)
          document.write('found:<a href="javascript:launchy('+t+')">'+list[t].name+'</a> ' +list[t].id+'<br/>');
        };
    
        onLaunch = function(activity) {
          if (activity.status == "running") {
            cv_activity = activity;
            // update UI to reflect that the receiver has received the
            // launch command and should start video playback.
          } else if (activity.status == "error") {
            cv_activity = null;
          }
        };
    
        function launchy(idx)
        {
          doLaunch(g_list[idx]);
        }
        doLaunch = function(receiver) {
          var request = new window.cast.LaunchRequest(">>>>>what REALLY goes here?<<<<<<< ", receiver);
          request.parameters = "v=abcdefg";
    
          request.description = new window.cast.LaunchDescription();
          request.description.text = "My Cat Video";
          request.description.url = "http://my.website.get.your.own/chomecast/test.php";
          cast_api.launch(request, onLaunch);
        };
    
        stopPlayback = function() {
          if (cv_activity) {
            cast_api.stopActivity(cv_activity.activityId);
          }
        };
    
        </script>
    
    
        </body>
    
        </html>
    

    部分标记为“这里到底是什么?”是我认为错误的部分......我不能完全错。我的设备是白名单,我有一个appid(我认为可能会在那个插槽中)...文档只是说ActivityType DIAL Parmeters是有效的,强制性的。

1 个答案:

答案 0 :(得分:1)

LaunchRequest的第一个参数是您的App ID,即您在电子邮件中收到的作为白名单流程一部分的ID。此外,初始化方法中的“YouTube”也应替换为相同的应用程序ID。

我强烈建议您查看GitHub上针对Chrome发送者的示例,以了解如何发送在转换设备上加载媒体的请求。