本文整理汇总了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));
}