Ejemplo n.º 1
0
        private void PlayBackButton_Click(object sender, RoutedEventArgs e)
        {
            string textArchive                   = textBackup;
            var    playbackStartPoint            = new TimeSpan(0);
            forUseByBackgroundWorker forPlayback = new forUseByBackgroundWorker(playbackStartPoint, savedRecordingAs);



            ClassPlayer.Open(new Uri(savedRecordingAs));
            // play.Open(new Uri(@"C:\SAMProjects\NoteRecorder\MicAndNotes\MicAndNotes\bin\Release6f6e0b14-623b-4c87-9cfd-eb3cf49fbf0c.wav"));
            ClassPlayer.Position = playbackStartPoint;
            ClassPlayer.Play();

            //var play = new MediaPlayer();

            //play.Open(new Uri(forPlayback.filePath));
            //play.Position = forPlayback.t;
            //play.Play();


            //bw.RunWorkerAsync(forPlayback);
            ThreadPool.QueueUserWorkItem(o =>
            {
                shouldContinue        = true;
                int counter           = 0;
                var playBackStopwatch = new Stopwatch();

                playBackStopwatch.Start();

                while (shouldContinue)
                {
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        try
                        {
                            if (playBackStopwatch.Elapsed + playbackStartPoint < timesForNote[counter].occurance)
                            {
                                Textbox.Text    = timesForNote[counter].note;
                                theSlider.Value = timesForNote[counter].occurance.Ticks;
                            }
                            else
                            {
                                counter++;
                            }
                        }
                        catch (Exception)
                        {
                            shouldContinue = false;
                            Textbox.Text   = textArchive;
                            Textbox.ScrollToEnd();
                            theSlider.Value = 0;
                        }
                    }));
                    Thread.Sleep(1);
                }
            });
        }
Ejemplo n.º 2
0
        private void FromCursor_Click(object sender, RoutedEventArgs e)
        {
            string textArchive = Textbox.Text;
            var toStart = new TimeSpan();
            int toPlayIndex = Textbox.CaretIndex;
            int lineIndex = Textbox.GetLineIndexFromCharacterIndex(toPlayIndex);
            String text = Textbox.GetLineText(lineIndex);
            for (int i = 0; i < timesForNote.Count; i++)
            {
                if (timesForNote[i].note.Contains(text))
                {
                    if (i > 0)
                    {
                        toStart = timesForNote[i - 1].occurance;
                    }
                    else
                    {
                        toStart = new TimeSpan(0);
                    }
                }
            }

            var playbackStartPoint = toStart;
            forUseByBackgroundWorker forPlayback = new forUseByBackgroundWorker(toStart, savedRecordingAs + ".wav");
            bw.RunWorkerAsync(forPlayback);
            ThreadPool.QueueUserWorkItem(o =>
            {
                bool shouldContinue = true;
                int counter = 0;
                var playBackStopwatch = new Stopwatch();

                playBackStopwatch.Start();

                while (shouldContinue)
                {
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        try
                        {
                            if (playBackStopwatch.Elapsed + playbackStartPoint < timesForNote[counter].occurance)
                            {
                                Textbox.Text = timesForNote[counter].note;
                                theSlider.Value = timesForNote[counter].occurance.Ticks;
                            }
                            else
                            {
                                counter++;
                            }
                        }
                        catch (Exception)
                        {
                            shouldContinue = false;
                            Textbox.Text = textArchive;
                            Textbox.ScrollToEnd();
                            theSlider.Value = 0;
                        }
                    }));
                    Thread.Sleep(1);
                }
            });
        }
Ejemplo n.º 3
0
        private void PlayBackButton_Click(object sender, RoutedEventArgs e)
        {
            string textArchive = textBackup;
            var playbackStartPoint = new TimeSpan(0);
            forUseByBackgroundWorker forPlayback = new forUseByBackgroundWorker(playbackStartPoint,savedRecordingAs+".wav");
            bw.RunWorkerAsync(forPlayback);
            ThreadPool.QueueUserWorkItem(o =>
            {
                bool shouldContinue = true;
                int counter = 0;
                var playBackStopwatch = new Stopwatch();

                playBackStopwatch.Start();

                while (shouldContinue)
                {
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        try
                        {
                            if (playBackStopwatch.Elapsed + playbackStartPoint < timesForNote[counter].occurance)
                            {
                                Textbox.Text = timesForNote[counter].note;
                                theSlider.Value = timesForNote[counter].occurance.Ticks;
                            }
                            else
                            {
                                counter++;
                            }
                        }
                        catch (Exception)
                        {
                            shouldContinue = false;
                            Textbox.Text = textArchive;
                            Textbox.ScrollToEnd();
                            theSlider.Value = 0;
                        }
                    }));
                    Thread.Sleep(1);
                }
            });
        }
Ejemplo n.º 4
0
        private void FromCursor_Click(object sender, RoutedEventArgs e)
        {
            var    toStart     = new TimeSpan();
            int    toPlayIndex = Textbox.CaretIndex;
            int    lineIndex   = Textbox.GetLineIndexFromCharacterIndex(toPlayIndex);
            String text        = Textbox.GetLineText(lineIndex);

            for (int i = 0; i < timesForNote.Count; i++)
            {
                if (timesForNote[i].note.Contains(text))
                {
                    if (i > 0)
                    {
                        toStart = timesForNote[i - 1].occurance;
                    }
                    else
                    {
                        toStart = new TimeSpan(0);
                    }
                }
            }



            string textArchive = textBackup;

            forUseByBackgroundWorker forPlayback = new forUseByBackgroundWorker(toStart, savedRecordingAs);

            ClassPlayer.Open(new Uri(savedRecordingAs));
            // play.Open(new Uri(@"C:\SAMProjects\NoteRecorder\MicAndNotes\MicAndNotes\bin\Release6f6e0b14-623b-4c87-9cfd-eb3cf49fbf0c.wav"));
            ClassPlayer.Position = toStart;
            ClassPlayer.Play();


            //bw.RunWorkerAsync(forPlayback);
            ThreadPool.QueueUserWorkItem(o =>
            {
                shouldContinue        = true;
                int counter           = 0;
                var playBackStopwatch = new Stopwatch();

                playBackStopwatch.Start();

                while (shouldContinue)
                {
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        try
                        {
                            if (playBackStopwatch.Elapsed + toStart < timesForNote[counter].occurance)
                            {
                                Textbox.Text    = timesForNote[counter].note;
                                theSlider.Value = timesForNote[counter].occurance.Ticks;
                            }
                            else
                            {
                                counter++;
                            }
                        }
                        catch (Exception)
                        {
                            shouldContinue = false;
                            Textbox.Text   = textArchive;
                            Textbox.ScrollToEnd();
                            theSlider.Value = 0;
                        }
                    }));
                    Thread.Sleep(1);
                }
            });
        }