Esempio n. 1
0
        public async Task <ActionResult> Video(string id)
        {
            var model = new HomeVideoModel();


            // Code Here


            if (model.Video == null)
            {
                throw new Exception("Video not found!");
            }

            return(View(model));
        }
Esempio n. 2
0
        public async Task <ActionResult> Video(string id)
        {
            var model = new HomeVideoModel();

            var courseRepo = VideoRepositoryFactory.Create();

            model.Video = await courseRepo.Get(id);

            if (model.Video == null)
            {
                throw new Exception("Video not found!");
            }

            // Get Access Token
            var client = new System.Net.Http.HttpClient();

            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", System.Configuration.ConfigurationManager.AppSettings["VideoIndexerAPI_Key"]);

            var uriAccountsResponse = await client.GetAsync("https://api.videoindexer.ai/auth/trial/Accounts");

            var jsonUriAccountsResponse = await uriAccountsResponse.Content.ReadAsStringAsync();

            dynamic accounts = Newtonsoft.Json.Linq.JArray.Parse(jsonUriAccountsResponse);
            var     videoIndexerAccountId = accounts[0].id;

            model.AccountId = videoIndexerAccountId.ToString();

            var uriResponse = await client.GetAsync($"https://api.videoindexer.ai/auth/trial/Accounts/{videoIndexerAccountId}/Videos/{model.Video.VideoId}/AccessToken");

            var jsonUriResponse = await uriResponse.Content.ReadAsStringAsync();

            model.AccessToken = jsonUriResponse.Replace("\"", string.Empty);


            return(View(model));
        }