如何使用 Bot Framework 版本 3 在 Skype 中显示音频和视频?
How to display the Audio and Video in Skype using Bot Framework version 3?
我正在研究机器人框架技术,在我的一个项目中,我实现了显示音频文件和视频文件的概念,为此我必须在 MessagesController 中编写以下代码行。
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
Activity replyToConversation = activity.CreateReply("Welcome to **Marriott Hotels**." + "(Hi)");
replyToConversation.Recipient = activity.From;
replyToConversation.Type = "message";
//replyToConversation.AttachmentLayout = AttachmentLayouts.Carousel;
replyToConversation.Attachments = new List<Attachment>();
if (activity != null && activity.GetActivityType() == "message" && activity.Text.ToLower() == "video")
{
replyToConversation.Attachments.Add(new Attachment()
{
ContentUrl = "https://1drv.ms/v/s!At-JUB9_wu9Ct3LEMJtNj_ZP26r6",
ContentType = "video/mp4",
Name = "xxxxx hotel video"
});
var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
}
else if (activity != null && activity.GetActivityType() == "message" && activity.Text.ToLower() == "file")
{
replyToConversation.Attachments.Add(new Attachment()
{
ContentUrl = "https://codeload.github.com/jeffhollan/BotFrameworkSample/zip/master",
ContentType = "application/zip",
Name = "Download ZIP File"
});
var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
}
else if (activity != null && activity.GetActivityType() == "message" && activity.Text.ToLower() == "audio")
{
replyToConversation.Attachments.Add(new Attachment()
{
//ContentUrl = "http://gaana.com/song/ulagam-oruvanukka",
ContentUrl = "http://www.zzz.com/eatfood.wav",
ContentType = "audio/wav",
Name = "Play Audio" + "(Music)"
});
var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
}
添加代码并将我的应用程序发布到 Azure 并添加 Skype 频道后,现在我开始与我的机器人聊天,然后它显示视频提示,但是当我单击它时它没有播放,它显示如下图所示的错误。
请告诉我如何解决这个问题。
普拉迪普
您发送的 link 是 link 到托管视频的网页,而不是 link 到视频本身,因此无法在网络电话。
要获取 link 到实际视频,您需要单击 "Download" 按钮,然后读取网络流量以获取实际视频 link。
对于 Chrome 浏览器,您可以按 F12 打开开发人员工具,然后单击 "Network" 选项卡。如果您按 "download" 过滤,您应该会看到您需要的 url。
我正在研究机器人框架技术,在我的一个项目中,我实现了显示音频文件和视频文件的概念,为此我必须在 MessagesController 中编写以下代码行。
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
Activity replyToConversation = activity.CreateReply("Welcome to **Marriott Hotels**." + "(Hi)");
replyToConversation.Recipient = activity.From;
replyToConversation.Type = "message";
//replyToConversation.AttachmentLayout = AttachmentLayouts.Carousel;
replyToConversation.Attachments = new List<Attachment>();
if (activity != null && activity.GetActivityType() == "message" && activity.Text.ToLower() == "video")
{
replyToConversation.Attachments.Add(new Attachment()
{
ContentUrl = "https://1drv.ms/v/s!At-JUB9_wu9Ct3LEMJtNj_ZP26r6",
ContentType = "video/mp4",
Name = "xxxxx hotel video"
});
var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
}
else if (activity != null && activity.GetActivityType() == "message" && activity.Text.ToLower() == "file")
{
replyToConversation.Attachments.Add(new Attachment()
{
ContentUrl = "https://codeload.github.com/jeffhollan/BotFrameworkSample/zip/master",
ContentType = "application/zip",
Name = "Download ZIP File"
});
var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
}
else if (activity != null && activity.GetActivityType() == "message" && activity.Text.ToLower() == "audio")
{
replyToConversation.Attachments.Add(new Attachment()
{
//ContentUrl = "http://gaana.com/song/ulagam-oruvanukka",
ContentUrl = "http://www.zzz.com/eatfood.wav",
ContentType = "audio/wav",
Name = "Play Audio" + "(Music)"
});
var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
}
添加代码并将我的应用程序发布到 Azure 并添加 Skype 频道后,现在我开始与我的机器人聊天,然后它显示视频提示,但是当我单击它时它没有播放,它显示如下图所示的错误。
您发送的 link 是 link 到托管视频的网页,而不是 link 到视频本身,因此无法在网络电话。
要获取 link 到实际视频,您需要单击 "Download" 按钮,然后读取网络流量以获取实际视频 link。
对于 Chrome 浏览器,您可以按 F12 打开开发人员工具,然后单击 "Network" 选项卡。如果您按 "download" 过滤,您应该会看到您需要的 url。