问题
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