简体   繁体   English

我可以为自己的需求定制Google Home的投射功能吗?

[英]Can I Implement a Casting Feature for Google Home Customized for My Needs?

I want to add a custom casting feature to my Google Home. 我想向我的Google Home添加自定义投射功能。 What I've done so far was the tutorial using Dialogflow from this page: https://developers.google.com/actions/dialogflow/first-app 到目前为止,我所做的是从以下页面开始的使用Dialogflow的教程: https : //developers.google.com/actions/dialogflow/first-app

Then I found a repo about casting videos to Chromecast, only from PC and not from Google Home: https://github.com/googlecast/CastHelloVideo-chrome/blob/master/helloVideos.js 然后,我找到了有关仅将视频从PC而不是从Google Home投射到Chromecast的回购协议: https : //github.com/googlecast/CastHelloVideo-chrome/blob/master/helloVideos.js

Then I tried combining the two. 然后我尝试将两者结合。 I've only tried to connect to my Chromecast so far, but I get this error every time: 到目前为止,我只尝试连接到我的Chromecast,但是每次都会出现此错误:

API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: ": Cannot find field.".

I made the tutorial work, so I didn't change anything on Dialogflow, only the index.js file. 我完成了本教程的工作,因此我没有对Dialogflow进行任何更改,仅更改了index.js文件。

This is my file: 这是我的文件:

 'use strict';

process.env.DEBUG = 'actions-on-google:*';
const App = require('actions-on-google').DialogflowApp;
const functions = require('firebase-functions');


// a. the action name from the make_name Dialogflow intent
const NAME_ACTION = 'game_cast';
// b. the parameters that are parsed from the make_name intent 
const COLOR_ARGUMENT = 'color';
const NUMBER_ARGUMENT = 'number';


exports.gameCast = functions.https.onRequest((request, response) => {
  const app = new App({request, response});
  console.log('Request headers: ' + JSON.stringify(request.headers));
  console.log('Request body: ' + JSON.stringify(request.body));


// c. The function that generates the silly name
  function gameCast (app) {
    let number = app.getArgument(NUMBER_ARGUMENT);
    let color = app.getArgument(COLOR_ARGUMENT);
//    app.tell('Alright, your silly name is ' +
//      color + ' ' + number +
//      '! I hope you like it. See you next time.');
    launchApp();
  }

  // d. build an action map, which maps intent names to functions
  let actionMap = new Map();
  actionMap.set(NAME_ACTION, gameCast);


app.handleRequest(actionMap);
});

The launchApp() function call in the gameCast function would connect to my Chromecast. gameCast函数中的launchApp()函数调用将连接到我的Chromecast。 Additionally I added the whole content of helloVideos.js, so there wouldn't be any missing functions that launchApp() may uses. 另外,我添加了helloVideos.js的全部内容,因此不会有launchApp()可能使用的任何缺少的函数。 (I didn't include my original file here, as the file helloVideos.js has 617 lines of code.) (我未在此处包括原始文件,因为文件helloVideos.js具有617行代码。)

Any suggestions would be greatly appreciated! 任何建议将不胜感激! Thanks! 谢谢!

" Cannot find field" comes when your google action intent name is different from gamecast on the api.ai console. 当您的Google动作意图名称与api.ai控制台上的Gamecast不同时,会出现“找不到字段”。

You can goto google cloud back end https://console.cloud.google.com and check the logging error. 您可以转到google cloud后端https://console.cloud.google.com并检查日志记录错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何实现需要持续运行的节点应用程序? - How can I implement my node application that needs to be constantly running? jQuery功能检测-如何实现此功能? - jquery feature detection - how can I implement this? 使用 React Js 实现自定义的 Google 日历? - Implement a customized Google Calendar with React Js? 如何在选择菜单中实现阵列功能? - How can I implement the array feature in a select menu? 当用户位于HOME页面时,如何选择导航栏中的“ HOME”链接? - What can I do so my “HOME” link in my navigation bar is selected when the user is at HOME page? 如何在我的网站中使用我自己定制的Sharethis图像以及sharethis插件? - How can i use my own customized Sharethis image along with sharethis plugin in my website? 我如何为需要“临时标头”的 api 实现 get 方法? - how i can implement a get method to a api what needs "Temporary Headers"? 如何为我的项目实现这个加载器? - How can I implement this loader for my project? 我可以在BigCommerce主页上使用第三方滑块吗 - Can I use a third party slider on my BigCommerce home page 重定向后如何将道具传递到我的家乡路线? - How can I pass a prop to my home route after redirecting?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM