//メディアの再生 private void play_Click(object sender, RoutedEventArgs e) { media.Play(); Uri video = media.Source; System.IO.StreamReader sr = new System.IO.StreamReader(@"C:\Users\matuyosi\Desktop\ヴァージョン\trunk\Authoring\Authoring\Butterfly.json"); //var j = JsonValue.Load(sr) as JsonValue; //List<TimeSpan> sync = new List<TimeSpan>(); //foreach (var value in (JsonArray)j["sync"]) //{ // sync.Add(TimeSpan.Parse(value)); //} var sync2 = TimeSpan.Parse("00:00:05.001"); var sync1 = TimeSpan.Parse("00:00:01.001"); var i = 0; var image1 = new Image { Source = new BitmapImage(new Uri("../marker.png", UriKind.Relative)), Margin = new Thickness(-10, 0, 0, 0), HorizontalAlignment = HorizontalAlignment.Left, Height = 20, Width = 20, Tag = i }; var image2 = new Image { Source = new BitmapImage(new Uri("../marker.png", UriKind.Relative)), Margin = new Thickness(-10, 0, 0, 0), HorizontalAlignment = HorizontalAlignment.Left, Height = 20, Width = 20, Tag = i }; if (media.NaturalDuration.HasTimeSpan) { if (!syncset) { Canvas.SetLeft(image1, sync1.TotalSeconds / media.NaturalDuration.TimeSpan.TotalSeconds * 320.0); markers.Children.Add(image1); Canvas.SetLeft(image2, sync2.TotalSeconds / media.NaturalDuration.TimeSpan.TotalSeconds * 320.0); markers.Children.Add(image2); //foreach (var value in sync) //{ // Canvas.SetLeft(image, value.TotalSeconds / media.NaturalDuration.TimeSpan.TotalSeconds * 320.0); // markers.Children.Add(image); //} syncset = true; } } MediaTimeline mediatimeline =new MediaTimeline(media.Source); Storyboard.SetTargetName(mediatimeline, media.Name); sb.Children.Add(mediatimeline); //sb.Begin(this,true); }
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; }
private void cmdPlayCode_Click(object sender, RoutedEventArgs e) { // Create the timeline. // This isn't required, but it allows you to configure details // that wouldn't otherwise be possible (like repetition). MediaTimeline timeline = new MediaTimeline(new Uri("test.mpg", UriKind.Relative)); timeline.RepeatBehavior = RepeatBehavior.Forever; // Create the clock, which is shared with the MediaPlayer. MediaClock clock = timeline.CreateClock(); MediaPlayer player = new MediaPlayer(); player.Clock = clock; // Create the VideoDrawing. VideoDrawing videoDrawing = new VideoDrawing(); videoDrawing.Rect = new Rect(150, 0, 100, 100); videoDrawing.Player = player; // Assign the DrawingBrush. DrawingBrush brush = new DrawingBrush(videoDrawing); this.Background = brush; // Start the timeline. clock.Controller.Begin(); }
public MediaPlayerControl() { InitializeComponent(); _timeline = new MediaTimeline(); _timeline.CurrentTimeInvalidated += CurrentTimeChanged; _timeline.Completed += MediaEnded; _timeline.CurrentStateInvalidated += ClockStateChanged; }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.GetCurrentValueAsFrozenCore(Freezable)">Freezable.GetCurrentValueAsFrozenCore</see>. /// </summary> protected override void GetCurrentValueAsFrozenCore(Freezable source) { MediaTimeline sourceTimeline = (MediaTimeline)source; base.GetCurrentValueAsFrozenCore(source); CopyCommon(sourceTimeline); }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.CloneCurrentValueCore(Freezable)">Freezable.CloneCurrentValueCore</see>. /// </summary> protected override void CloneCurrentValueCore(Freezable sourceFreezable) { MediaTimeline sourceTimeline = (MediaTimeline)sourceFreezable; base.CloneCurrentValueCore(sourceFreezable); CopyCommon(sourceTimeline); }
public MediaCanvas(string uri) { var timeline = new MediaTimeline(new Uri(uri)); var clock = timeline.CreateClock(); var player = new MediaPlayer {Clock = clock}; _video = new VideoDrawing {Player = player}; // clock.Controller.Stop(); }
public void InitializeMedia(string path) { mediaPlayer = new MediaPlayer(); _mTimeline = new MediaTimeline(new Uri(path)); _mTimeline.CurrentTimeInvalidated += MTimeline_CurrentTimeInvalidated; mediaPlayer.Clock = _mTimeline.CreateClock(true) as MediaClock; mediaPlayer.Clock.Controller.Stop(); mediaPlayer.MediaOpened += media_MediaOpened; }
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(); }
public MainWindow() { InitializeComponent(); _line = new MediaTimeline(new Uri(_threadURL)); _player.Clock = _line.CreateClock(true) as MediaClock; _isLoaded = new bool(); _lastVolumeValue = new double(); _player.MediaFailed += Player_Failed; _player.Clock.CurrentTimeInvalidated += Clock_TimeInvalidated; _player.BufferingStarted += Player_BufferingStarted; _player.BufferingEnded += Player_BufferingEnded; _player.Clock.CurrentStateInvalidated += Clock_StateInvalidated; }
public Window4() { InitializeComponent(); var tl = new MediaTimeline(new Uri(@"Media/Movie1.wmv", UriKind.Relative)); player.Clock = tl.CreateClock(true) as MediaClock; player.MediaOpened += (o, e) => { slider.Maximum = player.NaturalDuration.TimeSpan.Seconds; player.Clock.Controller.Pause(); }; slider.ValueChanged += (o, e) => { player.Clock.Controller.Seek(TimeSpan.FromSeconds(slider.Value), TimeSeekOrigin.BeginTime); }; }
public override MediaTimeline Create(DeterministicRandom random) { MediaTimeline mediaTimeline = null; RepeatBehavior repeatBehavior = RepeatBehavior.Forever; TimeSpan begintime = TimeSpan.FromSeconds(random.Next(60)); Duration playbackDuration = new Duration(TimeSpan.FromSeconds(random.Next(60))); switch (random.Next(4)) { case 0: //Initializes a new instance of a MediaTimeline class using the supplied Uri as the media source. mediaTimeline = new System.Windows.Media.MediaTimeline(Uri); break; case 1: //Initializes a new instance of the MediaTimeline that begins at the specified time. mediaTimeline = new System.Windows.Media.MediaTimeline(begintime); mediaTimeline.Source = Uri; break; case 2: //new instance of the MediaTimeline that begins at the specified time and lasts for the specified duration. mediaTimeline = new System.Windows.Media.MediaTimeline( begintime, playbackDuration); mediaTimeline.Source = Uri; break; case 3: mediaTimeline = new System.Windows.Media.MediaTimeline( begintime, playbackDuration, repeatBehavior); mediaTimeline.Source = Uri; break; } return(mediaTimeline); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.progress = ((System.Windows.Controls.ProgressBar)(target)); return; case 2: this.Mediapalyer = ((System.Windows.Controls.MediaElement)(target)); #line 19 "..\..\..\pipeMsg\VideoControl.xaml" this.Mediapalyer.MediaOpened += new System.Windows.RoutedEventHandler(this.Mediapalyer_MediaOpened); #line default #line hidden #line 19 "..\..\..\pipeMsg\VideoControl.xaml" this.Mediapalyer.MediaEnded += new System.Windows.RoutedEventHandler(this.Mediapalyer_MediaEnded); #line default #line hidden return; case 3: this.timeslider = ((System.Windows.Controls.Slider)(target)); #line 25 "..\..\..\pipeMsg\VideoControl.xaml" this.timeslider.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.timeslider_ValueChanged); #line default #line hidden return; case 4: this.Player = ((System.Windows.Controls.Button)(target)); #line 27 "..\..\..\pipeMsg\VideoControl.xaml" this.Player.Click += new System.Windows.RoutedEventHandler(this.Player_Click); #line default #line hidden return; case 5: this.Stop = ((System.Windows.Controls.Button)(target)); #line 28 "..\..\..\pipeMsg\VideoControl.xaml" this.Stop.Click += new System.Windows.RoutedEventHandler(this.Stop_Click); #line default #line hidden return; case 6: this.myBegin = ((System.Windows.Media.Animation.BeginStoryboard)(target)); return; case 7: this.storyboard = ((System.Windows.Media.Animation.Storyboard)(target)); return; case 8: this.timeline = ((System.Windows.Media.MediaTimeline)(target)); #line 37 "..\..\..\pipeMsg\VideoControl.xaml" this.timeline.CurrentTimeInvalidated += new System.EventHandler(this.timeline_CurrentTimeInvalidated); #line default #line hidden return; } this._contentLoaded = true; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.MainCanvas = ((System.Windows.Controls.Canvas)(target)); return; case 2: this.slider = ((System.Windows.Shapes.Rectangle)(target)); return; case 3: this.label1 = ((System.Windows.Controls.Label)(target)); return; case 4: this.introVideo = ((System.Windows.Controls.MediaElement)(target)); return; case 5: this.GRR = ((System.Windows.Media.MediaTimeline)(target)); return; case 6: this.label2 = ((System.Windows.Controls.Label)(target)); return; } this._contentLoaded = true; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.buttonHello = ((System.Windows.Controls.Button)(target)); return; case 2: this.labelMaxSample = ((System.Windows.Controls.Label)(target)); return; case 3: this.button3 = ((System.Windows.Controls.Button)(target)); #line 20 "..\..\..\XAML\CreateTeapotUserControl1.xaml" this.button3.Click += new System.Windows.RoutedEventHandler(this.button2_Click); #line default #line hidden return; case 4: this.mediaElementMaxRenderFile = ((System.Windows.Controls.MediaElement)(target)); return; case 5: this.button1 = ((System.Windows.Controls.Button)(target)); #line 24 "..\..\..\XAML\CreateTeapotUserControl1.xaml" this.button1.Click += new System.Windows.RoutedEventHandler(this.button1_Click); #line default #line hidden return; case 6: this.mediaTimelineMaxRenderFile = ((System.Windows.Media.MediaTimeline)(target)); return; } this._contentLoaded = true; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.progress = ((System.Windows.Controls.ProgressBar)(target)); return; case 2: this.Mediapalyer = ((System.Windows.Controls.MediaElement)(target)); #line 19 "..\..\..\pipeMsg\VideoControl.xaml" this.Mediapalyer.MediaOpened += new System.Windows.RoutedEventHandler(this.Mediapalyer_MediaOpened); #line default #line hidden #line 19 "..\..\..\pipeMsg\VideoControl.xaml" this.Mediapalyer.MediaEnded += new System.Windows.RoutedEventHandler(this.Mediapalyer_MediaEnded); #line default #line hidden return; case 3: this.timeslider = ((System.Windows.Controls.Slider)(target)); #line 25 "..\..\..\pipeMsg\VideoControl.xaml" this.timeslider.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler<double>(this.timeslider_ValueChanged); #line default #line hidden return; case 4: this.Player = ((System.Windows.Controls.Button)(target)); #line 27 "..\..\..\pipeMsg\VideoControl.xaml" this.Player.Click += new System.Windows.RoutedEventHandler(this.Player_Click); #line default #line hidden return; case 5: this.Stop = ((System.Windows.Controls.Button)(target)); #line 28 "..\..\..\pipeMsg\VideoControl.xaml" this.Stop.Click += new System.Windows.RoutedEventHandler(this.Stop_Click); #line default #line hidden return; case 6: this.myBegin = ((System.Windows.Media.Animation.BeginStoryboard)(target)); return; case 7: this.storyboard = ((System.Windows.Media.Animation.Storyboard)(target)); return; case 8: this.timeline = ((System.Windows.Media.MediaTimeline)(target)); #line 37 "..\..\..\pipeMsg\VideoControl.xaml" this.timeline.CurrentTimeInvalidated += new System.EventHandler(this.timeline_CurrentTimeInvalidated); #line default #line hidden return; } this._contentLoaded = true; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.mediaElement1 = ((System.Windows.Controls.MediaElement)(target)); #line 7 "..\..\media.xaml" this.mediaElement1.MediaOpened += new System.Windows.RoutedEventHandler(this.mediaElement1_MediaOpened_1); #line default #line hidden return; case 2: this.sbm = ((System.Windows.Media.Animation.BeginStoryboard)(target)); return; case 3: this.mediatimeline = ((System.Windows.Media.MediaTimeline)(target)); #line 15 "..\..\media.xaml" this.mediatimeline.CurrentTimeInvalidated += new System.EventHandler(this.mediatimeline_CurrentTimeInvalidated_1); #line default #line hidden return; case 4: this.Play = ((System.Windows.Controls.Grid)(target)); return; case 5: this.playGrid = ((System.Windows.Controls.Grid)(target)); return; case 6: this.Slider1 = ((System.Windows.Controls.Slider)(target)); return; case 7: this.text = ((System.Windows.Controls.TextBox)(target)); return; case 8: this.Open_MenuItem = ((System.Windows.Controls.MenuItem)(target)); #line 38 "..\..\media.xaml" this.Open_MenuItem.Click += new System.Windows.RoutedEventHandler(this.Open_Click); #line default #line hidden return; } this._contentLoaded = true; }
private void CopyCommon(MediaTimeline sourceTimeline) { _context = sourceTimeline._context; _baseUri = sourceTimeline._baseUri; }
protected MediaClock(MediaTimeline timeline) : base(timeline) { this.timeline = timeline; }
private void setVideo(Uri videoUri) { MediaTimeline mTimeLine = new MediaTimeline(videoUri); if (videoUri.ToString().Contains("Loop")) mTimeLine.RepeatBehavior = RepeatBehavior.Forever; MediaClock mClock = mTimeLine.CreateClock(); VideoPlayer.Clock = mClock; //VideoPlayer.Clock.Controller.Begin(); //VideoPlayer.Clock.Controller.Pause(); }
private void OpenVideo(VideoFile video) { storyboard?.Stop(mainGrid); storyboard = new Storyboard(); var timeline = new MediaTimeline(video.FileUri); storyboard.Children.Add(timeline); Storyboard.SetTarget(timeline, mediaElement); storyboard.CurrentTimeInvalidated += Storyboard_CurrentTimeInvalidated; Data.CurrentFile = video; storyboard.Begin(mainGrid, true); }
public void LoadVideo() { this.VideoPlayer.BeginInit(); var uri = new Uri(@"C:\tspdt4gq.r5g.wmv", UriKind.RelativeOrAbsolute); this.VideoPlayer.Source = uri; var mediaTimeLine = new MediaTimeline(uri); mediaTimeLine.CurrentTimeInvalidated += this.PositionChanged; mediaTimeLine.CurrentGlobalSpeedInvalidated += SpeedRatioChanged; VideoPlayer.Clock = mediaTimeLine.CreateClock(true) as MediaClock; var mediaClock = this.VideoPlayer.Clock; if (mediaClock != null) { if (mediaClock.Controller != null) { mediaClock.Controller.Stop(); } } this.VideoPlayer.LoadedBehavior = MediaState.Manual; this.VideoPlayer.UnloadedBehavior = MediaState.Manual; this.VideoPlayer.MediaOpened += delegate { AppViewModel.VideoPlayerControlViewModel.Duration = VideoPlayer.Clock.NaturalDuration.TimeSpan; //VideoSlider.Maximum = // WMPlayer.NaturalDuration.TimeSpan.TotalMilliseconds; //mre.Set(); }; this.VideoPlayer.EndInit(); this.VideoPlayer.Stop(); var clockController = this.VideoPlayer.Clock.Controller; if (clockController != null) { AppViewModel.VideoPlayerControlViewModel.SpeedRatio = clockController.SpeedRatio; } }
/// <summary> /// Creates a MediaClock object. /// </summary> /// <param name="media"> /// The MediaTimeline to use as a template. /// </param> /// <remarks> /// The returned MediaClock doesn't have any children. /// </remarks> protected internal MediaClock(MediaTimeline media) : base(media) { }
protected internal MediaClock(MediaTimeline media) : base(default(System.Windows.Media.Animation.Timeline)) { }
public void MediaElement_MediaOpened(object sender, EventArgs e) { var MediaElement = ((MediaElement)sender); var Slider = ((System.Windows.Controls.Slider)MediaElement.DataContext); var srVideo = (MeTLLib.DataTypes.Video)Slider.DataContext; MediaTimeline mt = new MediaTimeline((Uri)MediaElement.Source); MediaClock mc = mt.CreateClock(); MediaElement.Clock = mc; MediaElement.Clock.CurrentTimeInvalidated += (_sender, _e) => { if (Updating) { if (mc.NaturalDuration.HasTimeSpan) Slider.Maximum = mc.NaturalDuration.TimeSpan.TotalMilliseconds; if (mc.CurrentTime.HasValue) Slider.Value = mc.CurrentTime.Value.TotalMilliseconds; } }; MediaElement.Clock.Controller.Pause(); MediaElement.UpdateLayout(); var rectToPush = new Rectangle(); rectToPush.Fill = new VisualBrush(MediaElement); rectToPush.Stroke = Brushes.Red; rectToPush.Height = MediaElement.ActualHeight; rectToPush.Width = MediaElement.ActualWidth; Commands.MirrorVideo.ExecuteAsync(new MeTLLib.DataTypes.VideoMirror.VideoMirrorInformation(srVideo.tag().id, rectToPush)); }
protected internal MediaClock(MediaTimeline media) : base (default(System.Windows.Media.Animation.Timeline)) { }
/// <summary> /// questionで指定された曲ファイルをオープンします。 /// オープンが完了すると、MediaOpenedイベントが発生します。 /// </summary> /// <param name="question"></param> public void Open(SweetQuestion question) { Close(); _questionTimeLine = new MediaTimeline(new Uri(question.FileName)); //_questionTimeLine.Completed += question_Completed; CurrentQuestion = question; }
protected MediaClock (MediaTimeline timeline) : base (timeline) { this.timeline = timeline; }
/// <summary> /// Creates a MediaClock object. /// </summary> /// <param name="media"> /// The MediaTimeline to use as a template. /// </param> /// <remarks> /// The returned MediaClock doesn't have any children. /// </remarks> protected internal MediaClock(MediaTimeline media) : base(media) {}
private void CopyCommon(MediaTimeline sourceTimeline) { _context = sourceTimeline._context; _baseUri = sourceTimeline._baseUri; }
//---------------------------------------------------------// /// <summary> /// Load all the images/movies in the sample images/movies directories into the puzzle list. /// </summary> private void LoadPuzzleList() { // Load photo puzzles foreach (string file in Directory.GetFiles(photoPuzzlesPath, "*.jpg")) { // Load the photo Image img = new Image(); img.Source = new BitmapImage(new Uri(file)); // Add the photo to the list of possible photos AddElementToPuzzleList(img); } // Load video puzzles foreach (string file in Directory.GetFiles(videoPuzzlesPath, "*.wmv")) { // Load the video into a looping timeline MediaElement video = new MediaElement(); MediaTimeline t = new MediaTimeline(); t.Source = new Uri(file); t.RepeatBehavior = RepeatBehavior.Forever; video.Clock = t.CreateClock(); // Start the video with audio muted. video.IsMuted = true; video.Clock.Controller.Begin(); // Add the video to the list of possible puzzles. AddElementToPuzzleList(video); } }