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


C# MediaItem.ApplyPreset方法代码示例

本文整理汇总了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;
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:71,代码来源:EncodeJob.cs


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