Exemplo n.º 1
0
        SetClock(
            MediaClock clock,
            MediaPlayer player
            )
        {
            VerifyAPI();
            MediaClock oldClock = _mediaClock;
            MediaClock newClock = clock;

            // Avoid infinite loops
            if (oldClock != newClock)
            {
                _mediaClock = newClock;

                // Disassociate the old clock
                if (oldClock != null)
                {
                    oldClock.Player = null;
                }

                // Associate the new clock;
                if (newClock != null)
                {
                    newClock.Player = player;
                }

                // According to the spec, setting the Clock to null
                // should set the Source to null
                if (newClock == null)
                {
                    Open(null);
                }
            }
        }
Exemplo n.º 2
0
        public Test()
        {
            _viewModel = new MainWindowViewModel(DialogCoordinator.Instance);
            DataContext = _viewModel;
            InitializeComponent();
            var accent = ThemeManager.Accents.First(x => x.Name == "Purple");
           var theme = ThemeManager.GetAppTheme("BaseLight");
            ThemeManager.ChangeAppStyle(Application.Current, accent, theme);

            TaskEx.Delay(2000);
            homepage.IsEnabled = false;

            MediaTimeline timeline = new MediaTimeline(new Uri("Wildlife.wmv", UriKind.RelativeOrAbsolute));
            clock = timeline.CreateClock();//创建控制时钟
           
            MediaElement mediaElement = Resources["video"] as MediaElement;//得到资源
            orgin.Child = mediaElement;
            mediaElement.Clock = clock;
            clock.Controller.Seek(new TimeSpan(0, 0, 0, 2), TimeSeekOrigin.BeginTime);//跳过固定的时间线

            clock.Controller.Stop();

            clock.Controller.Begin();

            MainTabControl.SelectionChanged += MainTabControl_SelectionChanged;
            clock.Completed += Clock_Completed;
           


        }
Exemplo n.º 3
0
        /// <summary>
        /// Called by the Clock to create a type-specific clock for this
        /// timeline.
        /// </summary>
        /// <returns>
        /// A clock for this timeline.
        /// </returns>
        /// <remarks>
        /// If a derived class overrides this method, it should only create
        /// and return an object of a class inheriting from Clock.
        /// </remarks>
        protected internal override Clock AllocateClock()
        {
            if (Source == null)
            {
                throw new InvalidOperationException(SR.Get(SRID.Media_UriNotSpecified));
            }

            MediaClock mediaClock = new MediaClock(this);

            return(mediaClock);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Return the duration from a specific clock
        /// </summary>
        /// <param name="clock">
        /// The Clock whose natural duration is desired.
        /// </param>
        /// <returns>
        /// A Duration quantity representing the natural duration.
        /// </returns>
        protected override Duration GetNaturalDurationCore(Clock clock)
        {
            MediaClock mc = (MediaClock)clock;

            if (mc.Player == null)
            {
                return(Duration.Automatic);
            }
            else
            {
                return(mc.Player.NaturalDuration);
            }
        }
        public Window1()
        {
            InitializeComponent();
            MediaTimeline timeline = new MediaTimeline(new Uri("Wildlife.wmv", UriKind.RelativeOrAbsolute));
            clock = timeline.CreateClock();//创建控制时钟

            MediaElement mediaElement = Resources["video"] as MediaElement;//得到资源
            orgin.Child = mediaElement;
            mediaElement.Clock = clock;
            clock.Controller.Seek(new TimeSpan(0, 0, 0, 2), TimeSeekOrigin.BeginTime);//跳过固定的时间线

            clock.Controller.Stop();

            clock.Controller.Begin();
        }
 private void Reset()
 {
     Duration = 0;
     CurrentTime = 0;
     _clock = null;
     _controller = null;
     IsMediaLoaded = false;
     IsPlaying = false;
     IsPaused = false;
     _timeline.Source = null;
 }
        private void MediaOpened(object sender, RoutedEventArgs e)
        {
            if (MediaPlayerElement.Clock != null &&
                MediaPlayerElement.Clock.Controller != null)
            {
                _clock = MediaPlayerElement.Clock;
                _controller = MediaPlayerElement.Clock.Controller;

                IsMediaLoaded = true;
                _controller.Stop();
                if (_clock.NaturalDuration.HasTimeSpan)
                {
                    Duration = _clock.NaturalDuration.TimeSpan.TotalMilliseconds/1000;
                }
            }
            else
            {
                Reset();
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Called by the Clock to create a type-specific clock for this
        /// timeline.
        /// </summary>
        /// <returns>
        /// A clock for this timeline.
        /// </returns>
        /// <remarks>
        /// If a derived class overrides this method, it should only create
        /// and return an object of a class inheriting from Clock.
        /// </remarks>
        protected internal override Clock AllocateClock()
        {
            if (Source == null)
            {
                throw new InvalidOperationException(SR.Get(SRID.Media_UriNotSpecified));
            }

            MediaClock mediaClock = new MediaClock(this);

            return mediaClock;
        }
Exemplo n.º 9
0
			// (0.1.3.2)_timer.IsEnabledのチェックを追加。
			public void Close()
			{
				// アンドゥの時にしか呼ばれない!

				_questionMediaPlayer.Clock = null;
				//_questionMediaPlayer.Stop();
				_questionClock = null;
				_followClock = null;
				if (_timer != null && _timer.IsEnabled)
				{
					_timer.Stop();
				}
				NotifyPropertyChanged("CurrentPosition");
				_currentSongDuration = TimeSpan.Zero;
				NotifyPropertyChanged("Duration");
			}
Exemplo n.º 10
0
			public void Stop()
			{
				_questionClock.Controller.Pause();

				_questionTimeLine.Duration = System.Windows.Duration.Automatic;
				_followClock = (MediaClock)_questionTimeLine.CreateClock(true);
				_followClock.Controller.Seek(_questionMediaPlayer.Position, TimeSeekOrigin.BeginTime);

				_timer.Stop();

				this.QuestionStopped(this, EventArgs.Empty);

				// Clockを切り替えます。
				_questionMediaPlayer.Clock = _followClock;
				_followClock.Controller.Pause();

			}
Exemplo n.º 11
0
			public void Start()
			{
				// 停止位置設定を行う.
				if (CurrentQuestion.StopPos > TimeSpan.Zero)
				{
					_questionTimeLine.Duration = CurrentQuestion.StopPos;
				}

				// CurrentPosition更新通知用のタイマーを動かす。
				_timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(250) };
				_timer.Tick += (sender, e) => { NotifyPropertyChanged("CurrentPosition"); };


				// 再生を開始する。
				_questionClock = (MediaClock)_questionTimeLine.CreateClock(true);
				_questionClock.Controller.Seek(CurrentQuestion.PlayPos, TimeSeekOrigin.BeginTime);
				_questionClock.Completed += question_Completed;
				_questionMediaPlayer.Clock = _questionClock;
				_timer.Start();

			}
        SetClock(
            MediaClock  clock,
            MediaPlayer player
            )
        {
            VerifyAPI();
            MediaClock oldClock = _mediaClock;
            MediaClock newClock = clock;

            // Avoid infinite loops
            if (oldClock != newClock)
            {
                _mediaClock = newClock;

                // Disassociate the old clock
                if (oldClock != null)
                {
                    oldClock.Player = null;
                }

                // Associate the new clock;
                if (newClock != null)
                {
                    newClock.Player = player;
                }

                // According to the spec, setting the Clock to null
                // should set the Source to null
                if (newClock == null)
                {
                    Open(null);
                }
            }
        }