Exemplo n.º 1
0
        private void LoadMovies()
        {
            if (MediaElement1 != null)
            {
                MediaElement1.UnloadedBehavior = MediaState.Manual;
                MediaElement1.MediaOpened     -= MediaOpened;
                MediaElement1.Stop();
            }
            if (MediaElement2 != null)
            {
                MediaElement2.UnloadedBehavior = MediaState.Manual;
                MediaElement2.MediaOpened     -= MediaOpened;
                MediaElement2.Stop();
            }

            var movieController = MediaElementController.CreateController(_movieManager, 2);

            MediaElement1              = movieController.MediaElements[0];
            MediaElement2              = movieController.MediaElements[1];
            MediaElement1.MediaOpened += MediaOpened;
            if (MediaElement2 != null)
            {
                MediaElement2.MediaOpened += MediaOpened;
            }
            movieController.Start();
        }
 private void StopButtun_Click(object sender, RoutedEventArgs e)
 {
     MediaElement1.Stop();
     SeekSlider.Value       = 0;
     PauseButton.Visibility = Visibility.Hidden;
     PlayButton.Visibility  = Visibility.Visible;
 }
        private void Window_Closed(object sender, EventArgs e)
        {
            MediaElement1.Close();

            System.IO.FileInfo fi = new System.IO.FileInfo(System.Environment.CurrentDirectory + "\\temp.avi");
            fi.Delete();
            logwin.MainWin_Close();
        }
Exemplo n.º 4
0
        private void TimelineSlider_PreviewMouseUp(object sender, MouseButtonEventArgs e) //Resumes video when you release left mouse button
        {
            MediaElement1.Play();
            mDonSlider = false;
            TimeSpan ts = TimeSpan.FromSeconds(timelineSlider.Value);

            MediaElement1.Position = ts;
        }
Exemplo n.º 5
0
        private void Open_Click(object sender, RoutedEventArgs e)
        {
            aDialog.ShowDialog();
            MediaElement1.Source = new Uri(aDialog.FileName);
            this.Name.Content    = System.IO.Path.GetFileName(aDialog.FileName);

            MediaElement1.Play();
        }
Exemplo n.º 6
0
 //Open new file
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     aDialog.ShowDialog();
     MediaElement1.Source       = new Uri(aDialog.FileName);
     title.Content              = aDialog.FileName.Split('\\').Last();
     MediaElement1.MediaOpened += new RoutedEventHandler(mediaOpened);
     MediaElement1.Play();
 }
Exemplo n.º 7
0
        void OnSongTapped(IUICommand command)
        {
            SongView songView = (SongView)command.Id;

            MediaElement1.Source = new Uri(songView.Location);
            MediaElement1.Play();
            currentSong.SetSong(songView);
            StackPanelCurrentSong.DataContext = currentSong;
        }
Exemplo n.º 8
0
        private void Window_Drop(object sender, DragEventArgs e)
        {
            string filename = (string)((DataObject)e.Data).GetFileDropList()[0];

            MediaElement1.Source = new Uri(filename);

            MediaElement1.LoadedBehavior   = MediaState.Manual;
            MediaElement1.UnloadedBehavior = MediaState.Manual;
            MediaElement1.Play();
        }
Exemplo n.º 9
0
 /// <summary>
 /// 一時停止ボタン押下イベント
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void OnPauseButtonClick(object sender, RoutedEventArgs args)
 {
     try
     {
         // メディア一時停止
         MediaElement1.Pause();
     }
     catch
     {
         Debug.Assert(false, MethodBase.GetCurrentMethod().Name + "で例外が発生しました");
     }
 }
Exemplo n.º 10
0
 private void MediaElement1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) // play/pause on click vidio frame
 {
     if (isPlay)
     {
         MediaElement1.Pause();
         isPlay = false;
     }
     else
     {
         MediaElement1.Play();
         isPlay = true;
     }
 }
Exemplo n.º 11
0
 private void Play_Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         MediaElement1.Stop();
     }
     catch (Exception er)
     {
         //しょりしない
         logwin.AddLog(DateTime.Now, "Error: " + er.ToString());
     }
     MediaElement1.Play();
 }
Exemplo n.º 12
0
 void PlayPauseToggle()
 {
     if (playing)
     {
         MediaElement1.Pause();
         playing = false;
     }
     else
     {
         MediaElement1.Play();
         playing = true;
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// 视频开始与暂停
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (button.Content.ToString() == "播放")
     {
         MediaElement1.Play();
         button.Content = "暂停";
         getVideoName();
     }
     else
     {
         MediaElement1.Pause();
         button.Content = "播放";
         getVideoName();
     }
 }
Exemplo n.º 14
0
        private void PlaySong()
        {
            if (songViews.Count == 0)
            {
                return;
            }

            string location = songViews[songIndex].Location;

            MediaElement1.Source = new Uri(location);
            MediaElement1.Play();
            Windows.Media.MediaControl.TrackName  = songViews[songIndex].TITLE;
            Windows.Media.MediaControl.ArtistName = songViews[songIndex].ARTIST;
            currentSong.SetSong(songViews[songIndex]);
            StackPanelCurrentSong.DataContext = currentSong;
            playing = true;
        }
Exemplo n.º 15
0
        private async Task ClearTempData(string except = null)
        {
            try
            {
                MediaElement1?.Stop();
                IReadOnlyList <StorageFolder> storageFolder = await knownFolder.GetFoldersAsync();

                foreach (var item in storageFolder)
                {
                    if (item.Name != except)
                    {
                        await item.DeleteAsync(StorageDeleteOption.PermanentDelete);
                    }
                }
            }
            catch (Exception) { }
        }
Exemplo n.º 16
0
        void openfile()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Video files (*.mp4)|*.mp4|All files (*.*)|*.*";
            if (openFileDialog.ShowDialog() == true)
            {
                textBlock_dnd.Background = BackGround_ALPHA;
                textBlock_dnd.Text       = "";
                textBlock_dnd.IsEnabled  = false;

                var pathToFile = openFileDialog.FileName;
                MediaElement1.Source = new Uri(openFileDialog.FileName);
                MediaElement1.Play();
                isOpen = false;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 打开视频文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            string         url            = String.Empty;
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title            = "选择文件";
            openFileDialog.Filter           = "rmvb文件|*.rmvb|mp4文件|*.mp4|avi文件|*.avi|mkv文件|*.mkv";
            openFileDialog.FilterIndex      = 1;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.DefaultExt       = "rmvb";
            if (openFileDialog.ShowDialog() == true)
            {
                url = openFileDialog.FileName;
                MediaElement1.Source = new Uri(url);
                MediaElement1.Play();
            }
        }
Exemplo n.º 18
0
 void DropEvent(DragEventArgs e)
 {
     string[] dropContent = (string[])e.Data.GetData(DataFormats.FileDrop);
     pathToFile = dropContent[0].ToString();
     if (pathToFile.EndsWith(".mp4"))
     {
         isOpen = false;
         MediaElement1.Source = new Uri(pathToFile);
         MediaElement1.Play();
         textBlock_dnd.Text       = "";
         textBlock_dnd.Background = BackGround_ALPHA;
     }
     else
     {
         textBlock_dnd.Text       = "\n\n\n\n\n\nFile not mp4";
         textBlock_dnd.Background = BackGround_ERROR;
     }
 }
Exemplo n.º 19
0
        private void Button_Click_3(object sender, RoutedEventArgs e)//load
        {
            Microsoft.Win32.OpenFileDialog openf = new Microsoft.Win32.OpenFileDialog();
            openf.AddExtension = true;

            openf.Filter           = "Video Files (*.mp4)|*.mp4|Video Files (*.mpeg)|*.mpeg|Video Files (*.wmv)|*.wmv";
            openf.FilterIndex      = 0;
            openf.RestoreDirectory = true;
            openf.ShowDialog();
            MediaElement1.Play();
            try
            {
                MediaElement1.Source = new Uri(openf.FileName);
            }
            catch
            {
                new NullReferenceException("Error");
            }
        }
Exemplo n.º 20
0
        private async Task SetVideo(MediaComposition mediaComposition, CancellationToken cancellationToken)
        {
            StorageFile temporaryFile = await CreateFile("Video", "temp (1)", "mp4", cancellationToken);

            IAsyncOperationWithProgress <TranscodeFailureReason, double> progress = mediaComposition.RenderToFileAsync(temporaryFile, MediaTrimmingPreference.Precise);

            CancelTask(cancellationToken);

            progress.Progress = new AsyncOperationProgressHandler <TranscodeFailureReason, double>(async(reason, progressInfo) =>
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    reason.Cancel();
                    await ClearTempData();
                }
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(async() =>
                {
                    ReportProgress(Stage6, Stage5ProgressBar, TextProgress5, progressInfo);
                    if (progressInfo == 100)
                    {
                        Open.Content   = "Browse File";
                        ItemSource     = await GetProperties(temporaryFile, cancellationToken);
                        Save.IsEnabled = true;
                    }
                }));
            });

            CancelTask(cancellationToken);

            MediaStreamSource mediaStreamSource = mediaComposition.GeneratePreviewMediaStreamSource(0, 0);

            MediaElement1.SetMediaStreamSource(mediaStreamSource);

            MediaElement1.Play();

            await progress;

            CancelTask(cancellationToken);

            audioVideo.Add(temporaryFile);
        }
Exemplo n.º 21
0
 void AddToContext()
 {
     Registry.ClassesRoot.OpenSubKey("SystemFileAssociations\\.mp4", true).CreateSubKey("shell");
     Registry.ClassesRoot.OpenSubKey("SystemFileAssociations\\.mp4\\shell", true).CreateSubKey("CutVideo").SetValue("", "Cut Video");
     Registry.ClassesRoot.OpenSubKey("SystemFileAssociations\\.mp4\\shell\\CutVideo", true).CreateSubKey("command").SetValue("", Environment.GetCommandLineArgs()[0] + " \"%1\"");
     Registry.ClassesRoot.OpenSubKey("SystemFileAssociations\\.mp4\\shell\\CutVideo", true).SetValue("Icon", Environment.GetCommandLineArgs()[0]);
     if (Environment.GetCommandLineArgs().Length > 1)
     {
         if (Environment.GetCommandLineArgs()[1].EndsWith(".mp4"))
         {
             textBlock_dnd.Text   = Environment.GetCommandLineArgs()[1].ToString();
             MediaElement1.Source = new Uri(Environment.GetCommandLineArgs()[1]);
             MediaElement1.Play();
             textBlock_dnd.Text       = "";
             textBlock_dnd.Background = BackGround_ALPHA;
         }
         else
         {
             textBlock_dnd.Background = BackGround_ERROR;
             textBlock_dnd.Text       = "\n\n\n\n\nФайл неверного формата, нужон mp4";
         }
     }
 }
Exemplo n.º 22
0
 private void BtnPause_Click(object sender, RoutedEventArgs e)
 {
     MediaElement1.Pause();
 }
Exemplo n.º 23
0
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     MediaElement1.Stop();
 }
Exemplo n.º 24
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     MediaElement1.Pause();
 }
Exemplo n.º 25
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     MediaElement1.Play();
 }
Exemplo n.º 26
0
 private void Stop_Click(object sender, RoutedEventArgs e)
 {
     MediaElement1.Stop();
 }
Exemplo n.º 27
0
 private void Pause_Click(object sender, RoutedEventArgs e)
 {
     //TODO check if it's playing and pause it
     MediaElement1.Pause();
 }
Exemplo n.º 28
0
        //*************************     Button1_EventHandler        **************************************
        private async void Button1_Click(object sender, RoutedEventArgs e)
        {
            //Play The sound at MediaElement1
            MediaElement1.Play();


            // Messagedialoge Box that pops up after the sound has played! Adapted from http://stackoverflow.com/questions/22909329/universal-apps-messagebox-the-name-messagebox-does-not-exist-in-the-current
            //Cretaing new dialog with message!
            var dialog = new MessageDialog("Did you hear the sound?");

            //Title of Dialog
            dialog.Title = "Hear it?";

            //Option buttons that appear on the MessageDialogue along with unique IDs
            dialog.Commands.Add(new UICommand {
                Label = "Yes", Id = 0
            });
            dialog.Commands.Add(new UICommand {
                Label = "No", Id = 1
            });
            dialog.Commands.Add(new UICommand {
                Label = "Play Again", Id = 3
            });
            var result1 = await dialog.ShowAsync();

            res1 = (int)result1.Id;

            //if "Yes" is clicked
            if ((int)result1.Id == 0)
            {
                //Make Button1/MediaElement1/textBlock1 Collapsed
                Button1.Visibility       = Visibility.Collapsed;
                MediaElement1.Visibility = Visibility.Collapsed;
                textBlock1.Visibility    = Visibility.Collapsed;

                //Make Button2/MediaElement2/textBlock2 Visible
                Button2.Visibility       = Visibility.Visible;
                MediaElement2.Visibility = Visibility.Visible;
                textBlock2.Visibility    = Visibility.Visible;
            }
            // if "No" is clicked
            if ((int)result1.Id == 1)
            {
                //Make Button1/MediaElement1/textBlock1 Collapsed
                Button1.Visibility       = Visibility.Collapsed;
                MediaElement1.Visibility = Visibility.Collapsed;
                textBlock1.Visibility    = Visibility.Collapsed;

                //Make Button2/MediaElement2/textBlock2 Collapsed
                Button2.Visibility       = Visibility.Collapsed;
                MediaElement2.Visibility = Visibility.Collapsed;
                textBlock2.Visibility    = Visibility.Collapsed;

                //Make textBlockResult/SaveButton/HomeButton Visible
                textBlock1Result.Visibility = Visibility.Visible;
                SaveButton.Visibility       = Visibility.Visible;
                HomeButton.Visibility       = Visibility.Visible;
            }

            //If "Play Again" is clicked
            else if ((int)result1.Id == 3)
            {
                //Sound at MediaElement1 is palayed
                MediaElement1.Play();

                //Another MessageDialog PopsUp
                dialog       = new MessageDialog("Did you hear the sound this time?");
                dialog.Title = "This time?";

                dialog.Commands.Add(new UICommand {
                    Label = "Yes", Id = 0
                });
                dialog.Commands.Add(new UICommand {
                    Label = "No", Id = 1
                });
                result1 = await dialog.ShowAsync();


                //if "Yes" is clicked
                if ((int)result1.Id == 0)
                {
                    //Make Button1/MediaElement1/textBlock1 Collapsed
                    Button1.Visibility       = Visibility.Collapsed;
                    MediaElement1.Visibility = Visibility.Collapsed;
                    textBlock1.Visibility    = Visibility.Collapsed;

                    //Make Button2/MediaElement2/textBlock2 Visible
                    Button2.Visibility       = Visibility.Visible;
                    MediaElement2.Visibility = Visibility.Visible;
                    textBlock2.Visibility    = Visibility.Visible;
                }
                // if "No" is clicked
                if ((int)result1.Id == 1)
                {
                    //Make Button1/MediaElement1/textBlock1 Collapsed
                    Button1.Visibility       = Visibility.Collapsed;
                    MediaElement1.Visibility = Visibility.Collapsed;
                    textBlock1.Visibility    = Visibility.Collapsed;

                    //Make Button2/MediaElement2/textBlock2 Collapsed
                    Button2.Visibility       = Visibility.Collapsed;
                    MediaElement2.Visibility = Visibility.Collapsed;
                    textBlock2.Visibility    = Visibility.Collapsed;

                    //Make textBlockResult/SaveButton/HomeButton Visible
                    textBlock1Result.Visibility = Visibility.Visible;
                    SaveButton.Visibility       = Visibility.Visible;
                    HomeButton.Visibility       = Visibility.Visible;
                }
            }
        }
Exemplo n.º 29
0
 private void Button_Click_3(object sender, RoutedEventArgs e)
 {
     MediaElement1.Stop();
     Label1.Content = "Stopped.....";
 }
Exemplo n.º 30
0
 private void TimelineSlider_PreviewMouseDown(object sender, MouseButtonEventArgs e) //stops the video if you left mouse button has down on the timeline
 {
     MediaElement1.Pause();
     mDonSlider = true;
 }