Javascript 从Google Chrome发送时跳过Chromecast选择

Javascript 从Google Chrome发送时跳过Chromecast选择,javascript,google-chrome,chromecast,google-cast-sdk,Javascript,Google Chrome,Chromecast,Google Cast Sdk,我试图将数据发送到chromecast,但我想直接将数据发送到某个chromecast,而不必在Google Chrome中选择它 我想在发送数据之前跳过Chromecast选择 这是我们想要避免的 我不想选择强制转换,而是直接将数据强制转换到它 我一直在检查从chrome.cast.initialize获取的会话对象,它返回如下内容: { "sessionId": "b59f1754-fd13-48cd-b237-4952a69cade4", "ap

我试图将数据发送到chromecast,但我想直接将数据发送到某个chromecast,而不必在Google Chrome中选择它

我想在发送数据之前跳过Chromecast选择

这是我们想要避免的

我不想选择强制转换,而是直接将数据强制转换到它

我一直在检查从chrome.cast.initialize获取的会话对象,它返回如下内容:

      {
        "sessionId": "b59f1754-fd13-48cd-b237-4952a69cade4",
        "appId": "5B797F56",
        "displayName": "url-cast-sender",
        "statusText": "URL Cast ready...",
        "receiver": {
          "label": "rTflOUigItAIYPwoZZ87Uv5oK8yI.",
          "friendlyName": "Sala de Juntas",
          "capabilities": [
            "video_out",
            "audio_out"
          ],
          "volume": {
            "controlType": "attenuation",
            "level": 1,
            "muted": false,
            "stepInterval": 0.05000000074505806
          },
          "receiverType": "cast",
          "isActiveInput": null,
          "displayStatus": null
        },
        "senderApps": [],
        "namespaces": [
          {
            "name": "urn:x-cast:com.google.cast.debugoverlay"
          },
          {
            "name": "urn:x-cast:com.url.cast"
          }
        ],
        "media": [],
        "status": "connected",
        "transportId": "b59f1754-fd13-48cd-b237-4952a69cade4"
      };
正如你们所看到的那个样,那个里有一个标签,我一直在尝试使用它,但什么也并没有

页面请求连接到chromecast的方式如下:

// click handlers
document.getElementById('requestSession').onclick = function () {
  chrome.cast.requestSession(sessionListener, onErr);
};
这似乎是谷歌Chrome中打开选择警报的部分


我的工作是一个fork,你可以查看一个演示。

结果表明,从前端部分是不可能的

所以我最终使用了一个名为created by的库,其中有一个控制器可以让你做这类事情,你可以找到一个例子

在使其工作时遇到了一些困难,并且在存储库中打开了一个问题,但最终自己解决了它

using System.Linq;
using System.Threading.Tasks;
using SharpCaster.Controllers;
using SharpCaster.Services;
using Xunit;

namespace SharpCaster.Test
{
    public class WebPageCastingTester
    {
        private ChromecastService _chromecastService;
        public WebPageCastingTester()
        {
            _chromecastService = ChromecastService.Current;
            var device = _chromecastService.StartLocatingDevices().Result;
            _chromecastService.ConnectToChromecast(device.First()).Wait(2000);
        }

        [Fact]
        public async void TestingLaunchingSharpCasterDemo()
        {
            var controller =  await _chromecastService.ChromeCastClient.LaunchWeb();
            await Task.Delay(4000);
            Assert.NotNull(_chromecastService.ChromeCastClient.ChromecastStatus.Applications.First(x => x.AppId == WebController.WebAppId));
            await controller.LoadUrl("https://www.windytv.com/");
            await Task.Delay(4000);
            Assert.Equal(_chromecastService.ChromeCastClient.ChromecastStatus.Applications.First(x => x.AppId == WebController.WebAppId).StatusText,
                "Now Playing: https://www.windytv.com/");
        }
    }
}