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


C# MediaElement.SetValue方法代码示例

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


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

示例1: CheckReadOnlyProperties

		public void CheckReadOnlyProperties ()
		{
			MediaElement m = new MediaElement ();

			Assert.AreEqual (0, (int) m.GetValue (MediaElement.AudioStreamCountProperty), "Get/AudioStreamCountProperty");
			Assert.Throws<ArgumentException> (delegate {
				m.SetValue (MediaElement.AudioStreamCountProperty, 1);
			});
			Assert.AreEqual (0, m.AudioStreamCount, "AudioStreamCount");

			Assert.AreEqual (0.0, (double) m.GetValue (MediaElement.BufferingProgressProperty), "Get/BufferingProgressProperty");
			Assert.Throws<ArgumentException> (delegate {
				m.SetValue (MediaElement.BufferingProgressProperty, 1.0);
			});
			Assert.AreEqual (0.0, m.BufferingProgress, "BufferingProgress");

			Assert.IsFalse ((bool) m.GetValue (MediaElement.CanPauseProperty), "Get/CanPauseProperty");
			Assert.Throws<ArgumentException> (delegate {
				m.SetValue (MediaElement.CanPauseProperty, true);
			});
			Assert.IsFalse (m.CanPause, "CanPause");

			Assert.IsFalse ((bool) m.GetValue (MediaElement.CanSeekProperty), "Get/CanSeekProperty");
			Assert.Throws<ArgumentException> (delegate {
				m.SetValue (MediaElement.CanSeekProperty, true);
			});
			Assert.IsFalse (m.CanSeek, "CanSeek");

			Assert.AreEqual (MediaElementState.Closed, (MediaElementState) m.GetValue (MediaElement.CurrentStateProperty), "Get/CurrentState");
			Assert.Throws<ArgumentException> (delegate {
				m.SetValue (MediaElement.CurrentStateProperty, MediaElementState.Stopped);
			});
			Assert.AreEqual (MediaElementState.Closed, m.CurrentState, "CurrentState");

			Assert.AreEqual (0.0, (double) m.GetValue (MediaElement.DownloadProgressOffsetProperty), "Get/DownloadProgressOffsetProperty");
			Assert.Throws<ArgumentException> (delegate {
				m.SetValue (MediaElement.DownloadProgressOffsetProperty, 1.0);
			});
			Assert.AreEqual (0.0, m.DownloadProgressOffset, "DownloadProgressOffset");

			Assert.AreEqual (0.0, (double) m.GetValue (MediaElement.DroppedFramesPerSecondProperty), "Get/DroppedFramesPerSecondProperty");
			Assert.Throws<ArgumentException> (delegate {
				m.SetValue (MediaElement.DroppedFramesPerSecondProperty, 1.0);
			});
			Assert.AreEqual (0.0, m.DroppedFramesPerSecond, "DroppedFramesPerSecond");

			Assert.AreEqual (0, ((Duration) m.GetValue (MediaElement.NaturalDurationProperty)).TimeSpan.Ticks, "Get/NaturalDurationProperty");
			Assert.Throws<ArgumentException> (delegate {
				m.SetValue (MediaElement.NaturalDurationProperty, Duration.Forever);
			});
			Assert.AreEqual (0.0, m.NaturalDuration.TimeSpan.Ticks, "NaturalDuration");

			Assert.AreEqual (0, (int) m.GetValue (MediaElement.NaturalVideoHeightProperty), "Get/NaturalVideoHeightProperty");
			Assert.Throws<ArgumentException> (delegate {
				m.SetValue (MediaElement.NaturalVideoHeightProperty, 1);
			});
			Assert.AreEqual (0, m.NaturalVideoHeight, "NaturalVideoHeight");

			Assert.AreEqual (0, (int) m.GetValue (MediaElement.NaturalVideoWidthProperty), "Get/NaturalVideoWidthProperty");
			Assert.Throws<ArgumentException> (delegate {
				m.SetValue (MediaElement.NaturalVideoWidthProperty, 1);
			});
			Assert.AreEqual (0, m.NaturalVideoWidth, "NaturalVideoWidth");

			Assert.AreEqual (0.0, (double) m.GetValue (MediaElement.RenderedFramesPerSecondProperty), "Get/RenderedFramesPerSecondProperty");
			Assert.Throws<ArgumentException> (delegate {
				m.SetValue (MediaElement.RenderedFramesPerSecondProperty, 1.0);
			});
			Assert.AreEqual (0.0, m.RenderedFramesPerSecond, "RenderedFramesPerSecond");
		}
开发者ID:dfr0,项目名称:moon,代码行数:70,代码来源:MediaElementTest.cs

示例2: TestInvalidValues

		public void TestInvalidValues()
		{
			MediaElement m = new MediaElement();
			Assert.Throws<InvalidOperationException>(delegate {
				m.SetValue (MediaElement.AttributesProperty, null);
			}, "#1");
			m.AudioStreamIndex = -1000;
			Assert.AreEqual (-1000, m.AudioStreamIndex, "#2");
			m.AudioStreamIndex = -1;
			Assert.IsNull(m.AudioStreamIndex, "#3");
			m.AudioStreamIndex = int.MaxValue;
			Assert.AreEqual(int.MaxValue, m.AudioStreamIndex, "#4");
			m.Balance = -10000;
			m.Balance = 10000;
			m.BufferingTime = TimeSpan.FromSeconds(-1000);
			Assert.Throws<Exception>(delegate { m.BufferingTime = TimeSpan.MaxValue; }, "#5");
			m.BufferingTime = TimeSpan.FromSeconds(1000);
			Assert.Throws<ArgumentNullException>(delegate { m.LicenseAcquirer = null; }, "#6");
			m.Position = TimeSpan.FromSeconds(-100);
			Assert.AreEqual(TimeSpan.Zero, m.Position, "#7");
			m.Position = TimeSpan.FromSeconds(1000000);
			Assert.AreEqual(TimeSpan.Zero, m.Position, "#8");
			m.Source = null;
			m.Volume = -1000;
			m.Volume = 10000;
		}
开发者ID:dfr0,项目名称:moon,代码行数:26,代码来源:MediaElementTest.cs


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