首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用c#从Twilio中检索视频记录

用c#从Twilio中检索视频记录
EN

Stack Overflow用户
提问于 2017-06-02 09:39:23
回答 1查看 222关注 0票数 0

我的要求是视频聊天,这是通过IOS手机或Android手机使用Twilio,我已经取得了我的网页中的视频,用户可以播放和下载

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-06-02 09:46:02

代码语言:javascript
复制
Index.cshtml

@{
    ViewBag.Title = "Index";
}
@model List<TwilioVideos.Controllers.HomeController.Recording>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
@*<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>*@
<h2>&nbsp;&nbsp;&nbsp;Twilio Recorded Videos List</h2>
<br />
@if (Model != null)
{
    int i = 1;
    <table class="table table-bordered table-striped" style="    margin: 10px;" >
        <thead>

            <tr class="bg-success">
                <th>S.no</th>
                <th>Date</th>
                <th>type</th>
                <th>videos</th>
                <th>status</th>
            </tr>
        </thead>

        @foreach (var item in Model)
        {
            if(@item.type=="video")
            {


            <tr class="bg-info">
                <td>&nbsp;&nbsp;@i</td>
                <td>@item.date_created</td>
                <td>@item.type</td>
                <td>

                    <video width="200" poster="/Images/mp4.jpg" controls>
                         <source src="@item.links.media" type="video/mp4">

                    </video>


                </td>
                <td>@item.status</td>
            </tr>
                i++;
        }
        }
    </table>
}


Home controller.cs

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net.Http;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Twilio.Clients;
using Twilio.Exceptions;
using Twilio.Http;
using Twilio.Jwt.AccessToken;
using Twilio.Rest.Video.V1.Room;
using System.Text;
using System.Net.Http.Headers;
using System.IO;



namespace TwilioVideos.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public class GroupingSids
        {
            public string participant_sid { get; set; }
            public string room_sid { get; set; }
        }

        public class Links
        {
            public string media { get; set; }
        }

        public class Recording
        {
            public string status { get; set; }
            public GroupingSids grouping_sids { get; set; }
            public string url { get; set; }
            public string container_format { get; set; }
            public string account_sid { get; set; }
            public string room_sid { get; set; }
            public string codec { get; set; }
            public string source_sid { get; set; }
            public string sid { get; set; }
            public int duration { get; set; }
            public string date_created { get; set; }
            public string type { get; set; }
            public int size { get; set; }
            public Links links { get; set; }
        }

        public class Meta
        {
            public int page { get; set; }
            public int page_size { get; set; }
            public string first_page_url { get; set; }
            public object previous_page_url { get; set; }
            public string url { get; set; }
            public object next_page_url { get; set; }
            public string key { get; set; }
        }

        public class RootObject
        {
            public List<Recording> recordings { get; set; }
            public Meta meta { get; set; }
        }











        private static Request BuildFetchRequest(FetchRoomRecordingOptions options, ITwilioRestClient client)
        {




             return new Request(
                Twilio.Http.HttpMethod.Get,
                Twilio.Rest.Domain.Video,
               "/v1/Recordings",
                client.Region,
               queryParams: options.GetParams()
            );

        }






        /*try */

        public ActionResult Index()
        {

            var options = new FetchRoomRecordingOptions(Roomsid, "");
            Twilio.TwilioClient.Init("SK0aXXXXXXXXXXXXXXXXXXXXXXXX", "q7XXXXXXXXXXXXXXXXXXXXXXXXX", "ACXXXXXXXXXXXXXXXXXXXXXXXX");
            var client = Twilio.TwilioClient.GetRestClient();








            var response = client.Request(BuildFetchRequest(options, client));
            var o = JsonConvert.DeserializeObject<RootObject>(response.Content);
            List<Recording> cd = new List<Recording>();
            cd = o.recordings.ToList();
            return View(cd);
        }






    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44325659

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档