public void Close()
        {
            //            _video.Player.Source = null;
            _video.Player.Clock.Controller.Stop();

            _video.Player = null;
            _video = null;
        }
Пример #2
1
 public WpfWrapper()
 {
     InitializeComponent();
     player = new MediaPlayer();
     var vd = new VideoDrawing();
     vd.Player = player;
     vd.Rect = new Rect(0, 0, 1, 1);
     var db = new DrawingBrush();
     db.Drawing = vd;
     video.Fill = db;
 }
Пример #3
0
        //------------------------------------------------------
        //
        //  Public Properties
        //
        //------------------------------------------------------

        private static void PlayerPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            VideoDrawing target = ((VideoDrawing)d);


            MediaPlayer oldV = (MediaPlayer)e.OldValue;
            MediaPlayer newV = (MediaPlayer)e.NewValue;

            System.Windows.Threading.Dispatcher dispatcher = target.Dispatcher;

            if (dispatcher != null)
            {
                DUCE.IResource targetResource = (DUCE.IResource)target;
                using (CompositionEngineLock.Acquire())
                {
                    int channelCount = targetResource.GetChannelCount();

                    for (int channelIndex = 0; channelIndex < channelCount; channelIndex++)
                    {
                        DUCE.Channel channel = targetResource.GetChannel(channelIndex);
                        Debug.Assert(!channel.IsOutOfBandChannel);
                        Debug.Assert(!targetResource.GetHandle(channel).IsNull);
                        target.ReleaseResource(oldV, channel);
                        target.AddRefResource(newV, channel);
                    }
                }
            }

            target.PropertyChanged(PlayerProperty);
        }
Пример #4
0
        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();


        }
Пример #5
0
        private static void RectPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            VideoDrawing target = ((VideoDrawing)d);


            target.PropertyChanged(RectProperty);
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow" /> class.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            // var streamURI = ipi.StreamUri; // new Uri(@"http://127.0.0.1:8072");
            var streamURI = new Uri(@"http://127.0.0.1:8072");

            var savedStreams = SavedUriHandler.Streams.ToList();

            var lss = new LivestreamerSettings() { StreamUri = savedStreams[0].StreamUri, StreamQuality = savedStreams[0].Quality };
            var lss2 = new LivestreamerSettings() { StreamUri = savedStreams[1].StreamUri, StreamQuality = savedStreams[1].Quality };

            launch = new LSLauncher(lss);
            launch.Launch();

            MediaPlayer player = new MediaPlayer();
            player.Open(streamURI);
            VideoDrawing vd = new VideoDrawing();
            vd.Rect = new Rect(0, 0, 1920, 1080);
            vd.Player = player;
            player.Play();
            videoImage.Drawing = vd;
            vd.Freeze();
            player.Freeze();
        }
        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();
        }
Пример #8
0
        public void Init(MyModel mm)
        {
            this.mm = mm;
            Uri myValidMediaUri = new Uri(@"D:\Download\OdeToTheBrainCut.avi");

            MediaPlayer mp = new MediaPlayer();
            mp.Open(myValidMediaUri);
            vd = new VideoDrawing();
            vd.Player = mp;
            DrawingBrush db = new DrawingBrush();
            db.Drawing = vd;

            INameScope ins = NameScope.GetNameScope(mm.root);
            DiffuseMaterial dif = ins.FindName("dif") as DiffuseMaterial;
            dif.Brush = db;
            vd.Player.Play();
        }
        private void btnPlay_Click(object sender, RoutedEventArgs e)
        {
            MediaPlayer player;
            player = new MediaPlayer();

            player.Open(new Uri(@"Bear.wmv", UriKind.Relative));

            VideoDrawing aVideoDrawing = new VideoDrawing();

            aVideoDrawing.Rect = new Rect(0, 0, 100, 100);

            aVideoDrawing.Player = player;
            DrawingBrush db = new DrawingBrush(aVideoDrawing);
            rectangle1.Fill = db;
            //rectangle2.Fill = db;
            player.Play();
        }
Пример #10
0
        public VideoForm()
        {
            InitializeComponent();

            MediaPlayer player = new MediaPlayer();

            player.Open(new Uri(@"test.mp4", UriKind.Relative));

            VideoDrawing aVideoDrawing = new VideoDrawing();

            aVideoDrawing.Rect = new Rect(0, 0, 100, 100);
            aVideoDrawing.Player = player;

            DrawingImage di = new DrawingImage(aVideoDrawing);

            // Play the video once.
            player.Play();
        }
Пример #11
0
        private void cmdPlayCode_Click(object sender, RoutedEventArgs e)
        {
            // Create the MediaPlayer.
            MediaPlayer player = new MediaPlayer();
            player.Open(new Uri("test.mpg", UriKind.Relative));

            // 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 playback.
            player.Play();

        }
Пример #12
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 8 "..\..\MainWindow.xaml"
                ((VideoDrawingApp.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden
                return;

            case 2:
                this.video = ((System.Windows.Media.VideoDrawing)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #13
0
        void player_MediaOpened(object sender, EventArgs e)
        {
            try
            {
                if (_player != null)
                {
                    AdjustMovieSize();

                    PlayInfo info = _onePlay != null ? _onePlay : Config.Instance.PlayList.CurrentInfo;

                    // Playerの設定
                    if (_silent)
                        _player.Volume = 0;
                    else
                        _player.Volume = info.Volume;

                    // ムービーの追加
                    VideoDrawing videoDrawing = new VideoDrawing();
                    videoDrawing.Rect = new Rect(0, 0, _player.NaturalVideoWidth, _player.NaturalVideoHeight);
                    videoDrawing.Player = _player;
                    movRect.Fill = new DrawingBrush(videoDrawing);

                    System.Windows.Media.Effects.Effect ef = PlayInfo.DefaultEffect;
                    if (info.Effect != null)
                    {
                        ef = info.Effect;
                    }
                    movRect.Effect = ef;

                    // Play開始
                    _player.Play();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                PanelExit();
            }
        }
Пример #14
0
		void Player_MediaOpened (object sender, EventArgs e)
			{
			this.Top = VideoRectangle.Top;
			this.Left = VideoRectangle.Left;
			Player = sender as MediaPlayer;
			VideoDrawing DrawingFrame = new VideoDrawing ();
			DrawingFrame.Player = Player;
			double SourceAspectRatio = (double)Player.NaturalVideoWidth / (double)Player.NaturalVideoHeight;
			double TargetAspectRation = (double)VideoRectangle.Width / (double)VideoRectangle.Height;
			int NewWidth;
			int NewHeight;
			if (TargetAspectRation >= SourceAspectRatio)
				{
				NewHeight = (int) VideoRectangle.Height;
				NewWidth = (int)(VideoRectangle.Height * SourceAspectRatio);
				}
			else
				{
				NewWidth = (int) VideoRectangle.Width;
				NewHeight = (int)(VideoRectangle.Width / SourceAspectRatio);
				}
			//Rect CorrectedVideoRect = new Rect (VideoRectangle.Left, VideoRectangle.Top, NewWidth, NewHeight);
			Rect CorrectedVideoRect = new Rect (0, 0, NewWidth, NewHeight);
			this.MinWidth = NewWidth;
			this.MinHeight = NewHeight;
			DrawingFrame.Rect = CorrectedVideoRect;
						/*
						DrawingFrame.Rect = VideoRectangle;
						 */
			if (TimeToStop == DateTime.MinValue)
				TimeToStop = DateTime.Now + Player.NaturalDuration.TimeSpan;
			TimeSpan UnchangedDuration = (TimeToStop - DateTime.Now)
					- FadingDuration - FadingDuration - TimeSpan.FromMilliseconds (500);
			SetAnimationParameter (m_AnimationStoryBoard, FadingDuration, UnchangedDuration, FadingDuration,
				this, new PropertyPath (Window.OpacityProperty));
			this.Visibility = System.Windows.Visibility.Visible;
			m_AnimationStoryBoard.Begin (this);
			Player.Play ();
			DrawingBrush VideoBrush = new DrawingBrush (DrawingFrame);
			this.SizeToContent = SizeToContent.WidthAndHeight;
			this.Background = VideoBrush;
			if (Basics.IsTestRun)
				Basics.ReportInformationToEventViewer ("VideoWindow.Player_MediaOpened",
					"Player started mit File \"" + Player.Source.LocalPath
					+ "\"\r\nMinWidth = " + Convert.ToString (MinWidth)
					+ ", MinHeight = " + Convert.ToString (MinHeight)
					+ "\r\nTop = " + Convert.ToString (Top)
					+ ", Left = " + Convert.ToString (Left));
			this.Topmost = true;
			}
Пример #15
0
		void Player_MediaOpened (object sender, EventArgs e)

			{
			MediaPlayer Player = sender as MediaPlayer;
			VideoDrawing DrawingFrame = new VideoDrawing ();
			Duration NatuaralPlayLength = Player.NaturalDuration;
			DateTime ActualTime = m_HostCVM.GetDateTimeNow;
			DateTime ExpectedStopTime = ActualTime + NatuaralPlayLength.TimeSpan;
			if (LogWPMediaActivitiesCall != null)
				{
				try
					{
					String BeitragID = String.Empty;
					String BeitragName = String.Empty;
					if ((m_VideoPlayingData.FullBeitragDataSet.Tables ["Beitraege"] != null)
						&& (m_VideoPlayingData.FullBeitragDataSet.Tables ["Beitraege"].Rows.Count == 1))
						{
						BeitragName = m_VideoPlayingData.FullBeitragDataSet.Tables ["Beitraege"].Rows [0] ["Name"].ToString ();
						BeitragID = m_VideoPlayingData.FullBeitragDataSet.Tables ["Beitraege"].Rows [0] ["BeitragID"].ToString ();
						}

					LogWPMediaActivitiesCall ("RunVideo", "Video", BeitragName, BeitragID, ActualTime,
											  NatuaralPlayLength.TimeSpan);
					}
				catch (Exception Excp)
					{
					WMB.Basics.ReportErrorToEventViewer ("RunVideo.Player_MediaOpened",
						(Player != null) ? Player.Source.AbsolutePath : "Path not available:\r\n" + Excp.ToString());
					}
				}

			if (ExpectedStopTime > m_HostCVM.TimeToStop)
				{
				TimeSpan Difference = ExpectedStopTime - m_HostCVM.TimeToStop;
				if (Difference < NatuaralPlayLength.TimeSpan)
					Player.Position = Difference;
				}
			
			Player.Play ();
			DrawingFrame.Player = Player;
			DrawingBrush VideoBrush = new DrawingBrush (DrawingFrame);
			double SourceAspectRatio = (double) Player.NaturalVideoWidth / (double) Player.NaturalVideoHeight;
			((FrameworkElement)Parent).UpdateLayout ();
			double TargetAspectRatio = ((FrameworkElement)Parent).ActualWidth / ((FrameworkElement)Parent).ActualHeight;
			if (SourceAspectRatio >= TargetAspectRatio)
				{
				this.Width = (double)((FrameworkElement)Parent).ActualWidth;
				this.Height = (double)((FrameworkElement)Parent).ActualWidth / SourceAspectRatio;
				}
			else
				{
				this.Height = (double)((FrameworkElement)Parent).ActualHeight;
				this.Width = (double)((FrameworkElement)Parent).ActualHeight * SourceAspectRatio;
				}
			DrawingFrame.Rect = new Rect (0, 0, this.Width, this.Height);
//			DrawingFrame.Rect = new Rect(300, 150, this.Width - 600, this.Height - 300);
			this.Background = VideoBrush;
			}
Пример #16
0
        /// <summary>
        ///     DrawVideo - 
        ///     Draw a Video into the region specified by the Rect.
        ///     The Video will potentially be stretched and distorted to fit the Rect. 
        ///     For more fine grained control, consider filling a Rect with an VideoBrush via 
        ///     DrawRectangle.
        /// </summary> 
        /// <param name="player"> The MediaPlayer to draw. </param>
        /// <param name="rectangle">
        ///     The Rect into which the MediaPlayer will be fit.
        /// </param> 
        /// <param name="rectangleAnimations"> Optional AnimationClock for rectangle. </param>
        public override void DrawVideo( 
            MediaPlayer player, 
            Rect rectangle,
            AnimationClock rectangleAnimations) 
        {

        #if DEBUG
            MediaTrace.DrawingContextOp.Trace("DrawVideo(animate)"); 
        #endif
 
            // 
            // Verify that parameters & state are valid
            // 

            VerifyApiNonstructuralChange();

            if (player == null) 
            {
                return; 
            } 

            // 
            // Create a drawing & add animations if they exist
            //

            VideoDrawing videoDrawing = new VideoDrawing(); 

            // 
            // We may need to opt-out of inheritance through the new Freezable. 
            // This is controlled by this.CanBeInheritanceContext.
            // 

            videoDrawing.CanBeInheritanceContext = CanBeInheritanceContext;

            videoDrawing.Player = player; 
            videoDrawing.Rect = rectangle;
 
            SetupNewFreezable( 
                videoDrawing,
                false   // Don't ever freeze a VideoDrawing because it would 
                        // lose it's MediaPlayer
                );

            if (rectangleAnimations != null) 
            {
                videoDrawing.ApplyAnimationClock(VideoDrawing.RectProperty, rectangleAnimations); 
            } 

            AddDrawing(videoDrawing); 
        }
Пример #17
0
        /// <summary>
        /// CSV data load completed, adjust GUI if data was loaded successfully
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            CSVWorkerResult workerResult = (CSVWorkerResult)e.Result;
            if (workerResult.Success)
            {
                try
                {
                    emotionizer = workerResult.Emotionizer;

                    mp = new MediaPlayer();
                    mp.ScrubbingEnabled = true;
                    mp.MediaOpened += mp_MediaOpened;
                    mp.MediaEnded += mp_MediaEnded;

                    mp.Open(new Uri(MediaFilePathTextBox.Text));

                    VideoDrawing vd = new VideoDrawing();
                    vd.Player = mp;
                    vd.Rect = new Rect(0, 0, 100, 100);

                    DrawingBrush db = new DrawingBrush(vd);

                    MediaCanvas.Background = db;

                    SetControlButtonsEnabled(true);

                    SelectCsvFileButton.IsEnabled = false;
                    SelectMediaFileButton.IsEnabled = false;

                    ResetButton.IsEnabled = true;

                    csvDataProcessed = true;

                    eegGraph.PlotClear(1);
                    emotionGraph.PlotClear(1);
                    activityGraph.PlotClear(1);
                    spectrumGraph.PlotClear(1);

                    EEGZedGraphRefresh();

                    CurrentWaveComboBox.SelectedIndex = 0;
                    CurrentSpectrumComboBox.SelectedIndex = 0;
                    CurrentSpectrumSizeComboBox.SelectedIndex = 1;
                    OriginalWaveCheckBox.IsChecked = true;
                    AlphaActivityCheckBox.IsChecked = true;

                    DrawEEGLine();
                    DrawSpectrum();
                    DrawEmotions();
                    DrawActivities();
                }
                catch (System.IO.IOException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show(workerResult.ErrorMessage);
            }

            BusyBar.IsBusy = false;
        }