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

Posted

技术标签:

【中文标题】Chromecast Launch,DIAL 参数是啥?我不是在运行我的应用程序,而不是一些注册的标准吗?【英文标题】:Chromecast Launch, what's with the DIAL parameters? Aren't I runing MY application, not some registered standard?Chromecast Launch,DIAL 参数是什么?我不是在运行我的应用程序,而不是一些注册的标准吗? 【发布时间】:2014-01-03 06:19:46 【问题描述】:

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

    如果我正在制作自己的自定义应用程序,那么 DIAL 参数是什么?为什么我必须传递它们?我不想为 DIAL 标准编写应用程序……这是我的应用程序。 再次与 DIAL 参数相关,如果我搜索具有除“YouTube”(DIAL 参数)以外的任何其他查询的设备,列表总是空白。我想我应该不在乎,只要列出了设备……但同样……应用程序不会启动。

需要注意的是,我的发件人应用是一个 chrome 网页。

我对我的“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 参数是有效的,强制性的。

【问题讨论】:

【参考方案1】:

LaunchRequest 的第一个参数是您的 App ID,这是您在白名单过程中通过电子邮件收到的那个。此外,initialize 方法中的“YouTube”也应该替换为相同的 App ID。

我强烈建议您查看 GitHub 上的 chrome sender 示例,了解如何发送请求以在投射设备上加载媒体。

【讨论】:

谢谢...是的... GIT 示例非常完美!

以上是关于Chromecast Launch,DIAL 参数是啥?我不是在运行我的应用程序,而不是一些注册的标准吗?的主要内容,如果未能解决你的问题,请参考以下文章

DIAL: DIscovery And Launch简介

来自 ChromeCast 的 SSDP UDP 响应现在缺少 LOCATION 字段

从 WebRTC 启动 Chromecast

获取可投射设备的列表

ChromeCast 音频固件 1.24.88047 坏了?

VSCode - Launch.json指定参数