public static bool PublishJobAsset(this CloudMediaContext context, string jobId, out string encodedVideoUrl, out string thumbnailUrl)
        {
            encodedVideoUrl = null;
            thumbnailUrl    = null;
            var job = context.Jobs.Where(j => j.Id == jobId).FirstOrDefault();

            if ((job == null) || !(job.State == JobState.Finished || job.State == JobState.Canceled || job.State == JobState.Error))
            {
                return(false);
            }

            var encodingTask = job.Tasks.Where(t => t.Name == MediaServicesHelper.EncodingTask).FirstOrDefault();

            if (encodingTask != null)
            {
                var encodedAsset = encodingTask.OutputAssets.FirstOrDefault();
                if (encodedAsset != null)
                {
                    var manifestFile =
                        encodedAsset.AssetFiles.Where(f => f.Name.EndsWith(MediaServicesHelper.ManifestFileExtension)).FirstOrDefault();
                    if (manifestFile == null)
                    {
                        return(false);
                    }

                    var originLocator = context.CreateOriginLocator(encodedAsset);
                    encodedVideoUrl = originLocator.GetFileUrl(manifestFile);
                }
            }

            var thumbnailTask = job.Tasks.Where(t => t.Name == MediaServicesHelper.ThumbnailTask).FirstOrDefault();

            if (thumbnailTask != null)
            {
                var thumbnailAsset = thumbnailTask.OutputAssets.FirstOrDefault();
                if (thumbnailAsset != null)
                {
                    var thumbnailFile = thumbnailAsset.AssetFiles.FirstOrDefault();
                    if (thumbnailFile != null)
                    {
                        var sasLocator = context.CreateSasLocator(thumbnailAsset, AccessPermissions.Read, TimeSpan.FromDays(30.0));
                        thumbnailUrl = sasLocator.GetFileUrl(thumbnailFile.Name);
                    }
                }
            }

            BlockUntilFileIsAvailable(encodedVideoUrl);

            job.Delete();

            return(true);
        }
        public static string GetAssetVideoUrl(this CloudMediaContext context, IAsset asset)
        {
            var locator = context.CreateSasLocator(asset, AccessPermissions.Read, TimeSpan.FromDays(30));

            return(locator.GetFileUrl(asset.AlternateId));
        }