当前位置: 首页>>代码示例>>C#>>正文


C# IAsset.DownloadToFolder方法代码示例

本文整理汇总了C#中IAsset.DownloadToFolder方法的典型用法代码示例。如果您正苦于以下问题:C# IAsset.DownloadToFolder方法的具体用法?C# IAsset.DownloadToFolder怎么用?C# IAsset.DownloadToFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAsset的用法示例。


在下文中一共展示了IAsset.DownloadToFolder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PublishAssetGetURLs

        public static void PublishAssetGetURLs(IAsset asset)
        {
            // Publish the output asset by creating an Origin locator for adaptive streaming,
            // and a SAS locator for progressive download.

            _context.Locators.Create(
                LocatorType.OnDemandOrigin,
                asset,
                AccessPermissions.Read,
                TimeSpan.FromDays(30));

            _context.Locators.Create(
                LocatorType.Sas,
                asset,
                AccessPermissions.Read,
                TimeSpan.FromDays(30));

            IEnumerable<IAssetFile> mp4AssetFiles = asset
                    .AssetFiles
                    .ToList()
                    .Where(af => af.Name.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase));

            // Get the Smooth Streaming, HLS and MPEG-DASH URLs for adaptive streaming,
            // and the Progressive Download URL.
            Uri smoothStreamingUri = asset.GetSmoothStreamingUri();
            Uri hlsUri = asset.GetHlsUri();
            Uri mpegDashUri = asset.GetMpegDashUri();

            // Get the URls for progressive download for each MP4 file that was generated as a result
            // of encoding.
            List<Uri> mp4ProgressiveDownloadUris = mp4AssetFiles.Select(af => af.GetSasUri()).ToList();

            // Display  the streaming URLs.
            Console.WriteLine("Use the following URLs for adaptive streaming: ");
            Console.WriteLine(smoothStreamingUri);
            Console.WriteLine(hlsUri);
            Console.WriteLine(mpegDashUri);
            Console.WriteLine();

            // Display the URLs for progressive download.
            Console.WriteLine("Use the following URLs for progressive download.");
            mp4ProgressiveDownloadUris.ForEach(uri => Console.WriteLine(uri + "\n"));
            Console.WriteLine();

            // Download the output asset to a local folder.
            string outputFolder = "job-output";
            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }

            Console.WriteLine();
            Console.WriteLine("Downloading output asset files to a local folder...");
            asset.DownloadToFolder(
                outputFolder,
                (af, p) =>
                {
                    Console.WriteLine("Downloading '{0}' - Progress: {1:0.##}%", af.Name, p.Progress);
                });

            Console.WriteLine("Output asset files available at '{0}'.", Path.GetFullPath(outputFolder));
        }
开发者ID:debashish1976,项目名称:dotnetsdk,代码行数:62,代码来源:Program.cs


注:本文中的IAsset.DownloadToFolder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。