private static MediaTrack[] GetTextTracks(MediaClient mediaClient, IAsset asset, LocatorType locatorType) { List <MediaTrack> textTracks = new List <MediaTrack>(); string fileExtension = Constants.Media.FileExtension.WebVtt; string[] fileNames = MediaClient.GetFileNames(asset, fileExtension); foreach (string fileName in fileNames) { MediaTrack textTrack = new MediaTrack(); textTrack.Type = Constants.Media.Stream.TextTrackSubtitles; textTrack.Source = mediaClient.GetLocatorUrl(asset, locatorType, fileName); textTrack.Language = GetLanguageCode(textTrack.Source); textTracks.Add(textTrack); } return(textTracks.ToArray()); }
private static MediaMetadata[] GetAnalyticsProcessors(IAsset asset) { List <MediaMetadata> analyticsProcessors = new List <MediaMetadata>(); string fileExtension = Constants.Media.FileExtension.Json; string[] fileNames = MediaClient.GetFileNames(asset, fileExtension); foreach (string fileName in fileNames) { string processorName = GetAnalyticsProcessorName(fileName); MediaMetadata mediaMetadata = new MediaMetadata(); mediaMetadata.ProcessorName = processorName; mediaMetadata.MetadataFile = fileName; analyticsProcessors.Add(mediaMetadata); } return(analyticsProcessors.ToArray()); }
private static MediaStream[] GetMediaStreams(string authToken, MediaClient mediaClient, IAsset asset, bool clipperView, bool filtersOnly) { List <MediaStream> mediaStreams = new List <MediaStream>(); IndexerClient indexerClient = new IndexerClient(authToken); List <MediaInsight> contentInsight = new List <MediaInsight>(); if (!clipperView) { string documentId = DocumentClient.GetDocumentId(asset, out bool videoIndexer); if (!string.IsNullOrEmpty(documentId) && videoIndexer && indexerClient.IndexerEnabled) { MediaInsight insight = new MediaInsight() { ProcessorId = Processor.GetProcessorId(MediaProcessor.VideoIndexer, null), ProcessorName = Processor.GetProcessorName(MediaProcessor.VideoIndexer), DocumentId = documentId, SourceUrl = indexerClient.GetInsightUrl(documentId, true) }; contentInsight.Add(insight); } string[] fileNames = MediaClient.GetFileNames(asset, Constant.Media.FileExtension.Json); foreach (string fileName in fileNames) { string[] fileNameInfo = fileName.Split(Constant.TextDelimiter.Identifier); if (Enum.TryParse(fileNameInfo[0], out MediaProcessor processor) && fileNameInfo.Length == 2) { documentId = fileNameInfo[1].Replace(Constant.Media.FileExtension.Json, string.Empty); MediaInsight insight = new MediaInsight() { ProcessorId = Processor.GetProcessorId(processor, null), ProcessorName = Processor.GetProcessorName(processor), DocumentId = documentId, SourceUrl = string.Empty }; contentInsight.Add(insight); } } contentInsight.Sort(OrderByProcessor); } MediaStream mediaStream = new MediaStream() { Id = asset.Id, Name = asset.Name, Type = "asset", Source = new StreamSource() { Src = mediaClient.GetLocatorUrl(asset), ProtectionInfo = mediaClient.GetStreamProtections(authToken, asset) }, TextTracks = GetTextTracks(mediaClient, indexerClient, asset), ContentInsight = contentInsight.ToArray(), }; if (!filtersOnly) { mediaStreams.Add(mediaStream); } foreach (IStreamingAssetFilter assetFilter in asset.AssetFilters) { MediaStream filteredStream = mediaStream.DeepCopy(); filteredStream.Id = assetFilter.Id; filteredStream.Name = string.Concat(mediaStream.Name, "<br><br>+ ", assetFilter.Name); filteredStream.Type = "filter"; filteredStream.Source.Src = string.Concat(filteredStream.Source.Src, "(filter=", assetFilter.Name, ")"); mediaStreams.Add(filteredStream); } return(mediaStreams.ToArray()); }