本文整理汇总了C#中IJob.GetExecutionProgressTask方法的典型用法代码示例。如果您正苦于以下问题:C# IJob.GetExecutionProgressTask方法的具体用法?C# IJob.GetExecutionProgressTask怎么用?C# IJob.GetExecutionProgressTask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IJob
的用法示例。
在下文中一共展示了IJob.GetExecutionProgressTask方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertMP4toSmooth
private void ConvertMP4toSmooth(IAsset assetToConvert)
{
//0 Helper
IEncoderSupport myEncodigSupport = new EncoderSupport(_MediaServicesContext);
string xmlEncodeProfile = "H264 Adaptive Bitrate MP4 Set 1080p.xml";
//if (this.StepConfiguration != null)
if (!string.IsNullOrEmpty(this.StepConfiguration))
{
//TODO:support storage and LABEL
xmlEncodeProfile = this.StepConfiguration;
}
else
{
string txt = string.Format("StandarEncodeStep try to read StepConfiguration but it is not in configuration table! at {0} ", DateTime.Now.ToString());
Trace.TraceWarning(txt);
}
// Declare a new job to contain the tasks
currentJob = _MediaServicesContext.Jobs.Create("Convert to Smooth Streaming job " + myAssetOriginal.Name);
// Set up the first Task to convert from MP4 to Smooth Streaming.
// Read in task configuration XML
string configMp4ToSmooth = LoadEncodeProfile(xmlEncodeProfile);
// Get a media packager reference
//IMediaProcessor processor = GetLatestMediaProcessorByName("Windows Azure Media Encoder");
IMediaProcessor processor = myEncodigSupport.GetLatestMediaProcessorByName("Windows Azure Media Encoder");
// Create a task with the conversion details, using the configuration data
ITask task = currentJob.Tasks.AddNew("Task profile " + xmlEncodeProfile,
processor,
configMp4ToSmooth,
TaskOptions.None);
// Specify the input asset to be converted.
task.InputAssets.Add(assetToConvert);
// Add an output asset to contain the results of the job.
task.OutputAssets.AddNew(assetToConvert.Name+"_mb", AssetCreationOptions.None);
// Use the following event handler to check job progress.
// The StateChange method is the same as the one in the previous sample
//currentJob.StateChanged += new EventHandler<JobStateChangedEventArgs>(StateChanged);
currentJob.StateChanged += new EventHandler<JobStateChangedEventArgs>(myEncodigSupport.StateChanged);
// Launch the job.
currentJob.Submit();
//9. Revisa el estado de ejecución del JOB
Task progressJobTask = currentJob.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
myEncodigSupport.WaitJobFinish(currentJob.Id);
}
示例2: CreateEncodingJob
private IAsset CreateEncodingJob(IAsset workflow, IAsset video)
{
IEncoderSupport myEncodigSupport = new EncoderSupport(_MediaServicesContext);
// Declare a new job.
currentJob = _MediaServicesContext.Jobs.Create(myConfig.EncodingJobName);
// Get a media processor reference, and pass to it the name of the
// processor to use for the specific task.
IMediaProcessor processor = myEncodigSupport.GetLatestMediaProcessorByName("Media Encoder Premium Workflow");
// Create a task with the encoding details, using a string preset.
ITask task = currentJob.Tasks.AddNew(myConfig.EncodigTaskName, processor, "", TaskOptions.None);
// Specify the input asset to be encoded.
task.InputAssets.Add(workflow);
task.InputAssets.Add(video); // we add one asset
// Add an output asset to contain the results of the job.
// This output is specified as AssetCreationOptions.None, which
// means the output asset is not encrypted.
task.OutputAssets.AddNew(video.Name + "_mb", AssetCreationOptions.None);
// Use the following event handler to check job progress.
// The StateChange method is the same as the one in the previous sample
currentJob.StateChanged += new EventHandler<JobStateChangedEventArgs>(myEncodigSupport.StateChanged);
// Launch the job.
currentJob.Submit();
//9. Revisa el estado de ejecución del JOB
Task progressJobTask = currentJob.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
myEncodigSupport.WaitJobFinish(currentJob.Id);
return currentJob.OutputMediaAssets.FirstOrDefault();
}