本文整理汇总了C#中MediaItem.ApplyPreset方法的典型用法代码示例。如果您正苦于以下问题:C# MediaItem.ApplyPreset方法的具体用法?C# MediaItem.ApplyPreset怎么用?C# MediaItem.ApplyPreset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaItem
的用法示例。
在下文中一共展示了MediaItem.ApplyPreset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EncodeFile
/// <summary>
/// encode file to preset
/// </summary>
/// <param name="sourcePath">filepath to encode</param>
/// <param name="workingDirectory">working directory</param>
/// <param name="originalFilenameNoExt">original filename without extension</param>
/// <param name="presetPath">path to preset to use for this encoding</param>
/// <param name="logFile">logging file</param>
/// <returns>true if successful</returns>
private bool EncodeFile (string sourcePath, string workingDirectory, string originalFilenameNoExt, string presetPath, TraceListener logFile)
{
bool success = true;
string presetOutputDirectory = Path.Combine (this.directoryManager.OutputDirectory, Path.GetFileNameWithoutExtension (presetPath));
this.EncoderJob = new Job ();
try
{
logFile.WriteLine ("\r\n\r\n------------------------------------------------------------\r\n");
logFile.WriteLine ("Preset: " + Path.GetFileNameWithoutExtension (presetPath));
logFile.WriteLine ("Source: " + sourcePath);
Directory.CreateDirectory (presetOutputDirectory);
// encode
Preset preset = Preset.FromFile (presetPath);
MediaItem mediaItem = new MediaItem (sourcePath);
mediaItem.ApplyPreset (preset);
mediaItem.OutputFileName = "{Original file name}.Target.{Default extension}";
this.EncoderJob.MediaItems.Add (mediaItem);
this.EncoderJob.OutputDirectory = workingDirectory;
this.EncoderJob.CreateSubfolder = false;
this.EncoderJob.EncodeProgress += new EventHandler<EncodeProgressEventArgs> (this.Job_EncodeProgress);
this.EncoderJob.EncodeCompleted += new EventHandler<EncodeCompletedEventArgs> (this.Job_EncodeCompleted);
UserNotification.EncodingStarting (sourcePath + "->" + mediaItem.ActualOutputFileFullPath, EncodeInformation (mediaItem, "<br>"));
this.JobLog.WriteLine (EncodeInformation (mediaItem, "\r\n"));
if (this.EncodeStarted != null)
{
this.EncodeStarted (this, null);
}
this.EncoderJob.Encode ();
string outputSourcePath = Path.Combine (workingDirectory, mediaItem.ActualOutputFileName);
string outputTargetPath = Path.Combine (presetOutputDirectory, originalFilenameNoExt + Path.GetExtension (mediaItem.ActualOutputFileName));
Utilities.RenameFileMove (outputSourcePath, ref outputTargetPath, logFile);
logFile.WriteLine ("\r\n\r\nSuccess: Created Output file '" + outputTargetPath + "'");
if (this.EncodeEnded != null)
{
this.EncodeEnded (this, null);
}
}
catch (Exception ex)
{
logFile.WriteLine ("\r\n\r\nException: " + ex.Message);
success = false;
if (this.EncodeError != null)
{
this.EncodeError (this, null);
}
}
return success;
}