MS Bot Framework VideoCard

隐身守侯 提交于 2019-12-12 02:18:19

问题


Can someone please explain how you use the MediaUrl for the VideoCard? I've tried just adding the video url to the CardMedia which loads the media player but I can't play the video.

And whatever I try with MediaUrl I just get an error saying MediaUrl is not a funtion.

var url = new MediaUrl("Test", "https://www.youtube.com/watch?v=0i4v0Texqco");
var vid = new builder.Message(session)
          .textFormat(builder.TextFormat.xml)
          .attachments([
              new builder.MediaCard(session)
                  .title("Test title")
                  .media([
                      builder.CardMedia.create(session, url)
                  ])
          ]);
session.send(vid);

Thanks for any help!


回答1:


Per the VideoCard documentation and the MediaUrl documentation the url must be the one to the source of the video.

Using a YouTube URL in the VideoCard is not supported.

However, recently a "YouTube Card" was recently added to the WebChat/Emulator. If you are using WebChat, you might consider using that. See this and this for more information.




回答2:


For the Javascript solution the following code works pretty well, please note that it has been tested in bot framework emulator.

const {ActivityTypes } = require('botbuilder');
async playYoutube(context)
{
    const reply = { type: ActivityTypes.Message };
    reply.attachments = [this.getInlineAttachment()];
    await context.sendActivity(reply);
}

get the object:

getInlineAttachment() {
    return {
        name: 'YoutubeVideo',
        contentType: 'video/mp4',
        contentUrl: 'https://www.youtube.com/watch?v=-2JRiv3Mycs'
 }

hope this helps. Cheers



来源:https://stackoverflow.com/questions/42534155/ms-bot-framework-videocard

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!