在聊天机器人模拟器中自动播放视频

时间:2018-10-23 09:17:22

标签: c# .net

我正在向聊天机器人添加视频卡。

var resultMessage = context.MakeMessage();
            var bytes = System.IO.File.ReadAllBytes(HttpContext.Current.Server.MapPath("~/Videos/Cute.mp4"));
            string videoData = Convert.ToBase64String(bytes);
            resultMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            resultMessage.Attachments = new List<Microsoft.Bot.Connector.Attachment>();
            VideoCard vc = new VideoCard()
            {
                // Title = $"hi",
                // Subtitle = Address,
                Media = new List<MediaUrl>()
                    {
                        new MediaUrl()
                        {
                          // Url = "https://i1.wp.com/thefreshimages.com/wp-content/uploads/2017/12/lord-shiva-hd-images.jpg?resize=3840%2C2160&ssl=1"
                          Url = "data:video/mp4;base64,"+ videoData

                        },
                    }
            };
            resultMessage.Attachments.Add(vc.ToAttachment());

            await context.PostAsync(resultMessage);

它将在用户单击播放按钮时播放。但是我想自动播放。

1 个答案:

答案 0 :(得分:0)

here,默认情况下,“自动启动”属性为true,因此应自动开始播放。您可以尝试将其设置为true,然后查看是否可行。

VideoCard vc = new VideoCard()
{
    Media = new List<MediaUrl>()
    {
        new MediaUrl()
        {
            // Url = "https://i1.wp.com/thefreshimages.com/wp-content/uploads/2017/12/lord-shiva-hd-images.jpg?resize=3840%2C2160&ssl=1"
            Url = "data:video/mp4;base64,"+ videoData
        }
    },
    Autostart = true
};