public void removeMedia(AbMediaContent media)
        {
            MediaContentType mediaType = media.mediaType;

            if (mediaBoxes.ContainsKey(mediaType))
            {
                MediaCountBox mediaBox = mediaBoxes[mediaType];

                mediaBox.removeMedia(media);
                if (mediaBox.isOpen)
                {
                    Remove(media);
                }

                // Remove empty media boxes
                if (mediaBox.mediaCount == 0)
                {
                    Remove(mediaBox);
                    mediaBox.isOpen = false;
                }
            }

            else
            {
                Remove(media);
            }
        }
        /*
         * // TODO call a setMedia method from CardMediaCarouselPage!!!!
         * public void initialize(CardMediaCarouselPage cardMediaCarouselPage)
         * {
         *  this.cardMediaCarouselPage = cardMediaCarouselPage;
         * }
         */

        protected override async Task handleImageTapped(MediaContentType mediaType)
        {
            AbMediaContent otherMedia = await MediaCaptureUtilities.takeMedia(mediaType, base.card, base.parentPage);

            if (otherMedia != null)
            {
                LinkManager linkManager;

                if (card != null)
                {
                    linkManager = card.linkManager;
                }
                else
                {
                    linkManager = MediaManager.mediaLinkManager;
                }

                linkManager.addLink(this.rootMedia, otherMedia);

                if (card != null)
                {
                    card.saveToFile();
                }
                else
                {
                    MediaManager.saveMediaLinkManager();
                }
            }
        }
        public void addNewMedia(AbMediaContent media)
        {
            MediaContentType mediaType = media.mediaType;

            if (mediaBoxes.ContainsKey(mediaType))
            {
                MediaCountBox mediaBox = mediaBoxes[mediaType];

                mediaBox.addNewMedia(media);
                if (mediaBox.isOpen)
                {
                    Insert(IndexOf(mediaBox) + 1, media);
                }

                //Create media box if not present
                if (mediaBox.mediaCount == 1)
                {
                    Insert(getMediaBoxIndex(mediaType), mediaBox);
                }
            }

            else
            {
                Insert(getMediaIndex(), media);
            }
        }
示例#4
0
        public Preview(
            string externalId,
            MediaContentSource contentSource,
            MediaContentType contentType,
            string contentTitle,
            string contentDescription,
            Thumbnail thumbnail)
        {
            try
            {
                if (string.IsNullOrEmpty(contentTitle))
                {
                    throw new ArgumentException("Given title is null or empty");
                }

                ContentId   = new ContentId(externalId, contentSource, contentType);
                Title       = contentTitle;
                Description = contentDescription;
                Thumbnail   = thumbnail ?? throw new ArgumentNullException(nameof(thumbnail));
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException("Could not create preview", exception);
            }
        }
示例#5
0
 public static AbMediaContent createMediaContent(MediaContentType mediaType, String filePath)
 {
     if (mediaType == MediaContentType.Image)
     {
         return(new ImageMediaContent(filePath));
     }
     else if (mediaType == MediaContentType.Video)
     {
         return(new VideoMediaContent(filePath));
     }
     else if (mediaType == MediaContentType.Note)
     {
         return(new NoteMediaContent(filePath));
     }
     else if (mediaType == MediaContentType.Audio)
     {
         return(new AudioMediaContent(filePath));
     }
     else if (mediaType == MediaContentType.Contact)
     {
         return(new ContactMediaContent(filePath));
     }
     else
     {
         throw new Exception("ERROR - AbMediaContent.createMediaContent incorrect mediaType given");
     }
 }
示例#6
0
 public void showMediaType(MediaContentType mediaType)
 {
     if (!mediaTypesToShow.Contains(mediaType))
     {
         mediaTypesToShow.Add(mediaType);
         addItems(card.getMediaListByType(mediaType));
     }
 }
示例#7
0
        private void changeMediaType(MediaContentType mediaType)
        {
            curMediaType = mediaType;
            ObservableCollection <AbMediaContent> curMediaCollection = card.getMediaListByType(curMediaType);

            sortView.updateDataSet(curMediaCollection);
            headerView.initializeSearch(sortView.baseDataSet);
        }
 public JobFinishInfo(string ProcessId, string OriginalMp4, IJob FinishJob, MediaContentType AssetType, string AssetUri)
 {
     myAssetType = AssetType;
     myAssetUri = AssetUri;
     myFinishJob = FinishJob;
     myOriginalMp4 = OriginalMp4;
     myProcessId = ProcessId;
 }
示例#9
0
 public void hideMediaType(MediaContentType mediaType)
 {
     if (mediaTypesToShow.Contains(mediaType))
     {
         mediaTypesToShow.Remove(mediaType);
         removeItems(card.getMediaListByType(mediaType));
     }
 }
 public JobFinishInfo(string ProcessId, string OriginalMp4, IJob FinishJob, MediaContentType AssetType, string AssetUri)
 {
     myAssetType   = AssetType;
     myAssetUri    = AssetUri;
     myFinishJob   = FinishJob;
     myOriginalMp4 = OriginalMp4;
     myProcessId   = ProcessId;
 }
示例#11
0
        public ILocator GetDynamicStreamingUrl(string targetAssetID, LocatorType type, MediaContentType contentType)
        {
            IAssetFile assetFile = null;
            ILocator locator = null;
            Uri smoothUri = null;

            var daysForWhichStreamingUrlIsActive = 365;
            var outputAsset = myMediaServiceContext.Assets.Where(a => a.Id == targetAssetID).FirstOrDefault();
            var accessPolicy = myMediaServiceContext.AccessPolicies.Create(
                outputAsset.Name
                ,TimeSpan.FromDays(daysForWhichStreamingUrlIsActive)
                ,AccessPermissions.Read );
            var assetFiles = outputAsset.AssetFiles.ToList();
            switch (type)
            {
                case LocatorType.None:
                    break;
                case LocatorType.OnDemandOrigin:
                    assetFile = assetFiles.Where(f => f.Name.ToLower().EndsWith(".ism")).FirstOrDefault();
                    locator = myMediaServiceContext.Locators.CreateLocator(LocatorType.OnDemandOrigin, outputAsset, accessPolicy, DateTime.UtcNow.AddMinutes(-5));
                     switch (contentType)
	                {
                        case MediaContentType.SmoothStreaming:
                             smoothUri = new Uri(locator.Path + assetFile.Name + "/manifest");
                            break;
                        case MediaContentType.HLS:
                            smoothUri = new Uri(locator.Path + assetFile.Name + "/manifest(format=m3u8-aapl)");
                            break;
                        case MediaContentType.HDS:
                            smoothUri = new Uri(locator.Path + assetFile.Name + "/manifest(format=f4m-f4f)");
                            break;
                        case MediaContentType.DASH:
                            smoothUri = new Uri(locator.Path + assetFile.Name + "/manifest(format=mpd-time-csf)");
                            break;
                        default:
                            throw new Exception("GetDynamicStreamingUrl Error: you must chose HLS, Smooth or HDS");
                            break;
	                }
                    this.UrlForClientStreaming = smoothUri.ToString();
                 break;
                case LocatorType.Sas:
                     var mp4Files = assetFiles.Where(f => f.Name.ToLower().EndsWith(".mp4")).ToList();
                     assetFile = mp4Files.OrderBy(f => f.ContentFileSize).LastOrDefault(); //Get Largest File
                    if (assetFile != null)
                    {
                        locator = myMediaServiceContext.Locators.CreateLocator(LocatorType.Sas, outputAsset, accessPolicy, DateTime.UtcNow.AddMinutes(-5));
                        var mp4Uri = new UriBuilder(locator.Path);
                        mp4Uri.Path += "/" + assetFile.Name;
                        this.UrlForClientStreaming = mp4Uri.ToString();
                    }
                 break;
                default:
                 break;
            }
            return locator;
        }
示例#12
0
        // Create a locator URL to a streaming media asset
        // on an origin server.
        static public ILocator GetStreamingOriginLocator(IAsset assetToStream, MediaContentType contentType)
        {
            // Get a reference to the streaming manifest file from the
            // collection of files in the asset.
            var theManifest =
                from f in assetToStream.AssetFiles
                where f.Name.EndsWith(".ism")
                select f;

            // Cast the reference to a true IAssetFile type.
            IAssetFile manifestFile = theManifest.First();

            // Create a 30-day readonly access policy.
            IAccessPolicy policy = _context.AccessPolicies.Create("Streaming policy",
                                                                  TimeSpan.FromDays(30),
                                                                  AccessPermissions.Read);

            // Create a locator to the streaming content on an origin.
            ILocator originLocator = _context.Locators.CreateLocator(LocatorType.OnDemandOrigin, assetToStream,
                                                                     policy,
                                                                     DateTime.UtcNow.AddMinutes(-5));

            // Display some useful values based on the locator.
            // Display the base path to the streaming asset on the origin server.
            Console.WriteLine("Streaming asset base path on origin: ");
            Console.WriteLine(originLocator.Path);
            Console.WriteLine();

            // Create a full URL to the manifest file. Use this for playback
            // in streaming media clients.
            string urlForClientStreaming = originLocator.Path + manifestFile.Name + "/manifest";

            if (contentType == MediaContentType.HLS)
            {
                urlForClientStreaming = String.Format("{0}{1}", urlForClientStreaming, "(format=m3u8-aapl)");
            }

            Console.WriteLine("URL to manifest for client streaming: ");
            Console.WriteLine(urlForClientStreaming);
            Console.WriteLine();

            // For convenience, write the URL to a local file. Use the saved
            // streaming URL to browse directly to the asset in a smooth streaming client.
            string outFilePath = Path.GetFullPath(_outputFilesFolder + @"\" + "StreamingUrl.txt");

            WriteToFile(outFilePath, urlForClientStreaming);


            // Return the locator.
            return(originLocator);
        }
示例#13
0
        /// <summary>
        /// Handles execution of UpdateFileItemsCommand command.
        /// Updates a collection of available files' names.
        /// </summary>
        /// <param name="mediaContentType">Type of files to update.</param>
        private async void UpdateFileItems(string mediaContentType)
        {
            try
            {
                CanInitiateNewUpdate(false);
                MediaContentType type = (MediaContentType)Enum.Parse(typeof(MediaContentType), mediaContentType);
                _databaseManager.Connect();
                await _databaseManager.ScanFolderAsync(_storageRootDirectories);

                FileItems = _databaseManager.GetFileItems(SelectedStorageItems, type);
            }
            finally
            {
                CanInitiateNewUpdate(true);
                _databaseManager.Disconnect();
            }
        }
        private int getIndexAfterMediaBox(MediaContentType mediaType)
        {
            MediaCountBox mediaBox = mediaBoxes[mediaType];

            if (mediaBox.mediaCount > 0)
            {
                int mediaBoxIndex = IndexOf(mediaBox);
                if (mediaBox.isOpen)
                {
                    return(mediaBoxIndex + mediaBox.mediaCount + 1);
                }
                else
                {
                    return(mediaBoxIndex + 1);
                }
            }
            return(0);
        }
        public async static Task <AbMediaContent> takeMedia(MediaContentType mediaType, Card card, Page parentPage)
        {
            switch (mediaType)
            {
            case MediaContentType.Image:
                return(await takePicture(card, parentPage));

            case MediaContentType.Video:
                return(await takeVideo(card, parentPage));

            case MediaContentType.Audio:
                return(await takeAudio(card, parentPage));

            case MediaContentType.Note:
                return(await takeNote(card, parentPage));

            case MediaContentType.Contact:
                return(await takeContact(card, parentPage));
            }
            return(null);
        }
示例#16
0
        public ContentId(
            string externalId,
            MediaContentSource contentSource,
            MediaContentType contentType)
        {
            try
            {
                if (string.IsNullOrEmpty(externalId))
                {
                    throw new ArgumentException("External ID is null or empty");
                }

                ExternalId    = externalId;
                ContentSource = contentSource;
                ContentType   = contentType;
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException("Could not create content ID", exception);
            }
        }
        private int getMediaBoxIndex(MediaContentType mediaType)
        {
            int index;

            // Always insert audio as first
            if (mediaType == MediaContentType.Audio)
            {
                return(0);
            }

            // If possible, insert CONTACT after note
            else if (mediaType == MediaContentType.Contact)
            {
                index = getIndexAfterMediaBox(MediaContentType.Note);
                if (index != 0)
                {
                    return(index);
                }
            }

            //Insert after audio
            index = getIndexAfterMediaBox(MediaContentType.Audio);
            return(index);
        }
示例#18
0
        public void Create_preview()
        {
            string             actualExternalId  = "someId";
            MediaContentSource actualSource      = MediaContentSource.YouTube;
            MediaContentType   actualType        = MediaContentType.Video;
            string             actualTitle       = "sometitle";
            string             actualDescription = "somedescription";
            Thumbnail          actualThumbnail   = new Thumbnail(100, 100, "https://someurl.com");

            var preview = new Preview(
                actualExternalId,
                actualSource,
                actualType,
                actualTitle,
                actualDescription,
                actualThumbnail);

            Assert.Equal(actualExternalId, preview.ContentId.ExternalId);
            Assert.Equal(actualSource, preview.ContentId.ContentSource);
            Assert.Equal(actualType, preview.ContentId.ContentType);
            Assert.Equal(actualTitle, preview.Title);
            Assert.Equal(actualDescription, preview.Description);
            Assert.Equal(actualThumbnail.Url, preview.Thumbnail.Url);
        }
示例#19
0
    public AdMedia(Dictionary<string, object> data)
    {
        contentType = ContentTypeFromString(data["contentType"] as string);
        height = Convert.ToInt32(data["height"]);
        id = Convert.ToInt32(data["id"]);
        playTime = PlayTimeFromString(data["playTime"] as string);
        type = MediaTypeFromString(data["type"] as string);
        width = Convert.ToInt32(data["width"]);

        if (type == MediaType.Audio)
            AssignAudioFromURL(AdManager.MediaURL + id);
        else if (type == MediaType.Image)
        {
            //AssignImageFromURL(AdManager.MediaURL + id);
            foreach (string key in data.Keys)
            {
                if (key == "texture")
                {
                    image = data[key] as Texture2D;
                }
            }
        }
        else if (type == MediaType.Video)
            videoURL = AdManager.MediaURL + id;
    }
 protected virtual async Task handleImageTapped(MediaContentType mediaType)
 {
     await MediaCaptureUtilities.takeMedia(mediaType, card, parentPage);
 }
示例#21
0
 /// <summary>
 /// Gets files' information.
 /// </summary>
 /// <param name="storageIdItems">The collection of storages' IDs which are to be analyzed.</param>
 /// <param name="type">The type of file's content.</param>
 /// <returns>A collection of file's information items which meet the terms of filtering.</returns>
 public IEnumerable <FileInfo> GetFileItems(IEnumerable <string> storageIdItems, MediaContentType type)
 {
     return(_service.GetFileItems(storageIdItems, type));
 }
示例#22
0
 public MediaContent(LocaleAttributes name, MediaContentType contentType)
 {
     Name        = name;
     ContentType = contentType;
 }
        // Create a locator URL to a streaming media asset
        // on an origin server.
        private static ILocator GetStreamingOriginLocator(string targetAssetID, MediaContentType contentType)
        {
            // Get a reference to the asset you want to stream.
            IAsset assetToStream = GetAsset(targetAssetID);

            // Get a reference to the streaming manifest file from the
            // collection of files in the asset.
            var theManifest =
                                from f in assetToStream.AssetFiles
                                where f.Name.EndsWith(".ism")
                                select f;

            // Cast the reference to a true IAssetFile type.
            IAssetFile manifestFile = theManifest.First();

            // Create a 30-day readonly access policy.
            IAccessPolicy policy = _context.AccessPolicies.Create("Streaming policy",
                TimeSpan.FromDays(30),
                AccessPermissions.Read);

            // Create a locator to the streaming content on an origin.
            ILocator originLocator = _context.Locators.CreateLocator(LocatorType.OnDemandOrigin, assetToStream,
                policy,
                DateTime.UtcNow.AddMinutes(-5));

            // Display some useful values based on the locator.
            // Display the base path to the streaming asset on the origin server.
            Console.WriteLine("Streaming asset base path on origin: ");
            Console.WriteLine(originLocator.Path);
            Console.WriteLine();

            // Create a full URL to the manifest file. Use this for playback
            // in streaming media clients.
            string urlForClientStreaming = originLocator.Path + manifestFile.Name + "/manifest";
            if (contentType == MediaContentType.HLS)
                urlForClientStreaming = String.Format("{0}{1}", urlForClientStreaming, "(format=m3u8-aapl)");

            Console.WriteLine("URL to manifest for client streaming: ");
            Console.WriteLine(urlForClientStreaming);
            Console.WriteLine();

            // Display the ID of the origin locator, the access policy, and the asset.
            Console.WriteLine("Origin locator Id: " + originLocator.Id);
            Console.WriteLine("Access policy Id: " + policy.Id);
            Console.WriteLine("Streaming asset Id: " + assetToStream.Id);

            // For convenience, write the URL to a local file. Use the saved
            // streaming URL to browse directly to the asset in a smooth streaming client.
            string outFilePath = Path.GetFullPath(_outputFilesFolder + @"\" + "StreamingUrl.txt");
            WriteToFile(outFilePath, urlForClientStreaming);

            // Return the locator.
            return originLocator;
        }
示例#24
0
        protected override void OnBindingContextChanged()
        {
            if (this.BindingContext == null)
            {
                return;
            }

            AbMediaContent   media     = this.BindingContext as AbMediaContent;
            MediaContentType mediaType = media.mediaType;

            if (oldMediaType == mediaType)
            {
                base.OnBindingContextChanged();
                return;
            }

            hideAll();
            grid.BackgroundColor = Color.Transparent;

            base.OnBindingContextChanged();

            // Only show image once image loading is Finished
            switch (mediaType)
            {
            case MediaContentType.Image:
            case MediaContentType.Video:
            case MediaContentType.Card:
            case MediaContentType.MediaCount:
                image.Finish += Image_Finish;
                break;
            }

            //base.OnBindingContextChanged();

            switch (mediaType)
            {
            case MediaContentType.Image:
                this.image.IsVisible = true;
                break;

            case MediaContentType.Video:
                this.image.IsVisible      = true;
                this.videoImage.Source    = ImageSource.FromFile("VideoIcon.png");
                this.videoImage.IsVisible = true;
                break;

            case MediaContentType.Audio:
                this.nameLabel.IsEnabled = true;
                this.nameLabel.IsVisible = true;

                this.videoImage.Source    = ImageSource.FromFile("AudioIcon.png");
                this.videoImage.IsVisible = true;

                grid.BackgroundColor = Color.Coral;
                break;

            case MediaContentType.Note:
                this.nameLabel.IsEnabled = true;
                this.nameLabel.IsVisible = true;

                this.bodyLabel.IsEnabled = true;
                this.bodyLabel.IsVisible = true;

                grid.BackgroundColor = Color.LightYellow;
                break;

            case MediaContentType.Contact:
                this.image.IsVisible = true;

                this.videoImage.Source    = ImageSource.FromFile("ContactIcon.png");
                this.videoImage.IsVisible = true;
                break;

            case MediaContentType.MediaCount:
                this.image.IsVisible = true;

                this.countFrame.IsVisible = true;

                this.countLabel.IsEnabled = true;
                this.countLabel.IsVisible = true;
                break;

            case MediaContentType.Card:
                this.nameLabel.IsEnabled = true;
                this.nameLabel.IsVisible = true;

                grid.BackgroundColor = Color.LightGreen;
                break;
            }

            oldMediaType = mediaType;
        }
示例#25
0
        public ILocator GetDynamicStreamingUrl(string targetAssetID, LocatorType type, MediaContentType contentType)
        {
            IAssetFile assetFile = null;
            ILocator   locator   = null;
            Uri        smoothUri = null;

            var daysForWhichStreamingUrlIsActive = 365;
            var outputAsset  = myMediaServiceContext.Assets.Where(a => a.Id == targetAssetID).FirstOrDefault();
            var accessPolicy = myMediaServiceContext.AccessPolicies.Create(
                outputAsset.Name
                , TimeSpan.FromDays(daysForWhichStreamingUrlIsActive)
                , AccessPermissions.Read);
            var assetFiles = outputAsset.AssetFiles.ToList();

            switch (type)
            {
            case LocatorType.None:
                break;

            case LocatorType.OnDemandOrigin:
                assetFile = assetFiles.Where(f => f.Name.ToLower().EndsWith(".ism")).FirstOrDefault();
                locator   = myMediaServiceContext.Locators.CreateLocator(LocatorType.OnDemandOrigin, outputAsset, accessPolicy, DateTime.UtcNow.AddMinutes(-5));
                switch (contentType)
                {
                case MediaContentType.SmoothStreaming:
                    smoothUri = new Uri(locator.Path + assetFile.Name + "/manifest");
                    break;

                case MediaContentType.HLS:
                    smoothUri = new Uri(locator.Path + assetFile.Name + "/manifest(format=m3u8-aapl)");
                    break;

                case MediaContentType.HDS:
                    smoothUri = new Uri(locator.Path + assetFile.Name + "/manifest(format=f4m-f4f)");
                    break;

                case MediaContentType.DASH:
                    smoothUri = new Uri(locator.Path + assetFile.Name + "/manifest(format=mpd-time-csf)");
                    break;

                default:
                    throw new Exception("GetDynamicStreamingUrl Error: you must chose HLS, Smooth or HDS");
                    break;
                }
                this.UrlForClientStreaming = smoothUri.ToString();
                break;

            case LocatorType.Sas:
                var mp4Files = assetFiles.Where(f => f.Name.ToLower().EndsWith(".mp4")).ToList();
                assetFile = mp4Files.OrderBy(f => f.ContentFileSize).LastOrDefault();      //Get Largest File
                if (assetFile != null)
                {
                    locator = myMediaServiceContext.Locators.CreateLocator(LocatorType.Sas, outputAsset, accessPolicy, DateTime.UtcNow.AddMinutes(-5));
                    var mp4Uri = new UriBuilder(locator.Path);
                    mp4Uri.Path += "/" + assetFile.Name;
                    this.UrlForClientStreaming = mp4Uri.ToString();
                }
                break;

            default:
                break;
            }
            return(locator);
        }
示例#26
0
        private IJob ExecuteMasterJob(string JobEncodeDescription, string TaskEncodeDescription, IAsset myAsset, string OutPutAssetName, string EncodeDescription, MediaContentType TypeEncode, string MediaProcessorByName)
        {
            // 1. Configuration or encode label
            string ConfOrLabelEncode;

            if (EncodeDescription.Contains(".xml"))
            {
                if (File.Exists(EncodeDescription))
                {
                    ConfOrLabelEncode = File.ReadAllText(Path.GetFullPath(EncodeDescription));
                }
                else
                {
                    string xmlblobname = Path.GetFileName(EncodeDescription);

                    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.myConnConfigFiles);
                    CloudBlobClient     blobClient     = storageAccount.CreateCloudBlobClient();
                    CloudBlobContainer  container      = blobClient.GetContainerReference("wamsvodbutlerencodeconfig");
                    CloudBlockBlob      blockBlob2     = container.GetBlockBlobReference(xmlblobname);

                    string encodeConfigXml;
                    using (var memoryStream = new MemoryStream())
                    {
                        blockBlob2.DownloadToStream(memoryStream);
                        memoryStream.Position = 0;
                        StreamReader sr = new StreamReader(memoryStream);
                        encodeConfigXml = sr.ReadToEnd();
                    }
                    ConfOrLabelEncode = encodeConfigXml;
                }
            }
            else
            {
                //Encoding by name
                ConfOrLabelEncode = EncodeDescription;
            }


            //2. Onlu form HLS Valida que el Asset contenga un solo archivo ISM
            if (TypeEncode == MediaContentType.HLS)
            {
                var ismAssetFiles = myAsset.AssetFiles.ToList().
                                    Where(f => f.Name.EndsWith(".ism", StringComparison.OrdinalIgnoreCase)).ToArray();
                if (ismAssetFiles.Count() != 1)
                {
                    throw new ArgumentException("The asset should have only one, .ism file");
                }
                ismAssetFiles.First().IsPrimary = true;
                ismAssetFiles.First().Update();
            }
            // 3. Creal el JOB
            IJob            job       = myMediaServiceContext.Jobs.Create(JobEncodeDescription);
            IMediaProcessor processor = GetLatestMediaProcessorByName(MediaProcessorByName);

            // 4. Crea la tarea con los detalles de codificación del archivo XML
            ITask task = job.Tasks.AddNew(
                TaskEncodeDescription,
                processor,
                ConfOrLabelEncode,
                TaskOptions.ProtectedConfiguration);

            // 5. Define el Asset de entrada
            task.InputAssets.Add(myAsset);

            // 6. Crea el Asset de Salida con el sufijo HLS.
            string nombreContenido = OutPutAssetName;

            task.OutputAssets.AddNew(nombreContenido, AssetCreationOptions.None);

            //7. define el manejador del evento
            job.StateChanged += new EventHandler <JobStateChangedEventArgs>(StateChanged);

            //8. Lanza el JOB
            job.Submit();

            //9. Revisa el estado de ejecución del JOB
            Task progressJobTask = job.GetExecutionProgressTask(CancellationToken.None);

            //10. en vez de utilizar  progressJobTask.Wait(); que solo muestra cuando el JOB termina
            //se utiliza el siguiente codigo para mostrar avance en porcentaje, como en el portal
            this.WaitJobFinish(job.Id);
            //11. regresa la referencia al JOB terminado
            return(job);
        }
示例#27
0
 private void updateCurMediaType()
 {
     curMediaType = (audioNoteSwitch.IsToggled ? MediaContentType.Audio : MediaContentType.Note);
 }
示例#28
0
 public bool isMediaTypeOnlyVisible(MediaContentType mediaType)
 {
     return(mediaTypesToShow.Contains(mediaType) && mediaTypesToShow.Count == 1);
 }
示例#29
0
 public bool isMediaTypeVisible(MediaContentType mediaType)
 {
     return(mediaTypesToShow.Contains(mediaType));
 }
示例#30
0
        /*
         * public void toggleMediaVisibility(MediaContentType mediaType)
         * {
         *  if (mediaTypesToShow.Contains(mediaType))
         *  {
         *      hideMediaType(mediaType);
         *  }
         *  else
         *  {
         *      showMediaType(mediaType);
         *  }
         * }
         */

        public void showOnlyMediaType(MediaContentType mediaType)
        {
            hideAllMediaType();
            showMediaType(mediaType);
        }
示例#31
0
        private IJob ExecuteMasterJob(string JobEncodeDescription, string TaskEncodeDescription, IAsset myAsset, string OutPutAssetName, string EncodeDescription, MediaContentType TypeEncode, string MediaProcessorByName)
        {
            // 1. Configuration or encode label
            string ConfOrLabelEncode;
            if (EncodeDescription.Contains(".xml"))
            {
                if (File.Exists(EncodeDescription))
                {
                    ConfOrLabelEncode = File.ReadAllText(Path.GetFullPath(EncodeDescription));
                }
                else
                {
                    string xmlblobname = Path.GetFileName(EncodeDescription);

                    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.myConnConfigFiles);
                    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
                    CloudBlobContainer container = blobClient.GetContainerReference("wamsvodbutlerencodeconfig");
                    CloudBlockBlob blockBlob2 = container.GetBlockBlobReference(xmlblobname);

                    string encodeConfigXml;
                    using (var memoryStream = new MemoryStream())
                    {
                        blockBlob2.DownloadToStream(memoryStream);
                        memoryStream.Position = 0;
                        StreamReader sr= new StreamReader(memoryStream);
                        encodeConfigXml = sr.ReadToEnd();
                    }
                    ConfOrLabelEncode = encodeConfigXml;
                }
            }
            else
            {
                //Encoding by name
                ConfOrLabelEncode = EncodeDescription;
            }


            //2. Onlu form HLS Valida que el Asset contenga un solo archivo ISM
            if (TypeEncode == MediaContentType.HLS)
            {
                var ismAssetFiles = myAsset.AssetFiles.ToList().
                            Where(f => f.Name.EndsWith(".ism", StringComparison.OrdinalIgnoreCase)).ToArray();
                if (ismAssetFiles.Count() != 1)
                    throw new ArgumentException("The asset should have only one, .ism file");
                ismAssetFiles.First().IsPrimary = true;
                ismAssetFiles.First().Update();
            }
            // 3. Creal el JOB
            IJob job = myMediaServiceContext.Jobs.Create(JobEncodeDescription);
            IMediaProcessor processor = GetLatestMediaProcessorByName(MediaProcessorByName);

            // 4. Crea la tarea con los detalles de codificación del archivo XML
            ITask task = job.Tasks.AddNew(
                TaskEncodeDescription,
                processor,
                ConfOrLabelEncode,
                TaskOptions.ProtectedConfiguration);

            // 5. Define el Asset de entrada
            task.InputAssets.Add(myAsset);

            // 6. Crea el Asset de Salida con el sufijo HLS.
            string nombreContenido = OutPutAssetName;
            task.OutputAssets.AddNew(nombreContenido, AssetCreationOptions.None);

            //7. define el manejador del evento 
            job.StateChanged += new EventHandler<JobStateChangedEventArgs>(StateChanged);

            //8. Lanza el JOB
            job.Submit();

            //9. Revisa el estado de ejecución del JOB 
            Task progressJobTask = job.GetExecutionProgressTask(CancellationToken.None);

            //10. en vez de utilizar  progressJobTask.Wait(); que solo muestra cuando el JOB termina
            //se utiliza el siguiente codigo para mostrar avance en porcentaje, como en el portal
            this.WaitJobFinish(job.Id);
            //11. regresa la referencia al JOB terminado
            return job;
        }