// // GET: Display a list ofstreamable media assets public async Task<ActionResult> Index() { //Initializing a model MediaLibraryModel model = new MediaLibraryModel(); model.VideoList = new List<Tuple<IAsset, ILocator, Uri>>(); model.IsCurrentUserMemberOfAdminGroup = IsAdminUser(); model.JwtToken = GetJwtSecurityToken(); if (model.JwtToken == null) { return View(model); } try { CloudMediaContext cloudMediaContext = Factory.GetCloudMediaContext(); IStreamingEndpoint streamingEndPoint = cloudMediaContext.StreamingEndpoints.FirstOrDefault(); model.StreamingEndPoint = streamingEndPoint; // Find 30-day read-only access policy. string streamingPolicy = "30d Streaming policy"; var accessPolicy = cloudMediaContext.AccessPolicies.Where(c => c.Name == streamingPolicy).FirstOrDefault(); //Locate all files with smooth streaming Manifest ListExtensions.ForEach(cloudMediaContext.Files.Where(c => c.Name.EndsWith(".ism")), file => { //skip all assets where DynamicEncryption can't be applied if (file.Asset.Options != AssetCreationOptions.None) { return; } ILocator originLocator = null; //Display only assets which associated with streaming 30 day policy if (accessPolicy != null) originLocator = file.Asset.Locators.Where(c => c.AccessPolicyId == accessPolicy.Id && c.Type == LocatorType.OnDemandOrigin).FirstOrDefault(); //If no policy has been found we are storing nulls in a model Tuple<IAsset, ILocator, Uri> item = new Tuple<IAsset, ILocator, Uri>(file.Asset, originLocator, originLocator != null ? new Uri(originLocator.Path + file.Name) : null); model.VideoList.Add(item); }); return View(model); } catch (Exception ex) { ViewBag.ErrorMessage = ex.Message; return View(model); } }