Beispiel #1
0
        private void OnAudioRecordingFinished_(object sender, AudioRecorder.AudioRecordingFinishEventArgs e)
        {
            if (!Settings.Default.Audio_DisableSingleWavFileRecord)
            {
                if (m_RecordAndContinue_StopSingleFileRecord)
                {
                    m_RecordAndContinue_StopSingleFileRecord = false;
                    return;
                }
            }

            if (m_InterruptRecording)
            {
                m_RecordAndContinue  = false;
                m_InterruptRecording = false;
                checkAndAddDeferredRecordingDataItems();

                if (IsMonitoringAlways)
                {
                    CommandStartMonitor.Execute();
                }
                return;
            }

            if (!String.IsNullOrEmpty(e.RecordedFilePath))
            {
                registerRecordedAudioFileForDeferredAddition(e.RecordedFilePath);

                ////m_RecordAndContinue &&
                ////!Settings.Default.Audio_EnableSkippability
                //if (m_RecordAndContinue)
                //{

                //}
                //else
                //{
                //    openFile(e.RecordedFilePath, true, true, State.Audio.PcmFormatRecordingMonitoring);
                //}
            }

            if (m_RecordAndContinue)
            {
                if (!Settings.Default.Audio_DisableSingleWavFileRecord)
                {
#if DEBUG
                    DebugFix.Assert(IsRecording);
#endif
                }

                IsAutoPlay = false;

                Tuple <TreeNode, TreeNode> treeNodeSelection = m_UrakawaSession.GetTreeNodeSelection();
                TreeNode treeNode = treeNodeSelection.Item2 ?? treeNodeSelection.Item1;
                if (treeNode != null)
                {
                    //TreeNode next = electNextRecordableNode(treeNode);
tryNext:
                    //TreeNode nested;
                    //TreeNode next = TreeNode.GetNextTreeNodeWithNoSignificantTextOnlySiblings(false, treeNode, out nested);
                    TreeNode next = TreeNode.NavigatePreviousNextSignificantText(false, treeNode);
                    if (next != null)
                    {
                        TreeNode math = next.GetFirstAncestorWithXmlElement("math");
                        if (math != null)
                        {
                            next = math;
                        }
                        else
                        {
                            TreeNode svg = next.GetFirstAncestorWithXmlElement("svg");
                            if (svg != null)
                            {
                                next = svg;
                            }
                            else
                            {
                                TreeNode candidate = m_UrakawaSession.AdjustTextSyncGranularity(next, treeNode);
                                if (candidate != null)
                                {
                                    next = candidate;
                                }
                            }
                        }


                        if (Settings.Default.Audio_EnableSkippability && m_UrakawaSession.isTreeNodeSkippable(next))
                        {
                            treeNode = next;
                            goto tryNext;
                        }

                        m_StateToRestore = null;

                        m_UrakawaSession.PerformTreeNodeSelection(next, false, null); //nested);
                        State.Selection.ClearSelection();

                        //must appear after tree node selection!!!
                        m_RecordAndContinue = false;

                        if (!Settings.Default.Audio_DisableSingleWavFileRecord)
                        {
                            //RaisePropertyChanged(() => State.Audio.PcmFormatRecordingMonitoring);

                            //if (EventAggregator != null)
                            //{
                            //    EventAggregator.GetEvent<StatusBarMessageUpdateEvent>().Publish(Tobi_Plugin_AudioPane_Lang.Recording);
                            //}
                            //PCMFormatInfo pcmFormatInfo = State.Audio.GetCurrentPcmFormat();
                            OnStateChanged_Recorder(null,
                                                    new AudioRecorder.StateChangedEventArgs(AudioRecorder.State.Stopped));
                        }
                        else
                        {
                            State.Audio.PcmFormatRecordingMonitoring = null;
                        }

                        Tuple <TreeNode, TreeNode> treeNodeSelectionNew = m_UrakawaSession.GetTreeNodeSelection();
                        TreeNode treeNodeNew = treeNodeSelectionNew.Item2 ?? treeNodeSelectionNew.Item1;
                        if (treeNodeNew != null)
                        {
                            //#if DEBUG
                            //                    DebugFix.Assert(treeNodeNew == next);
                            //#endif //DEBUG

                            if (treeNodeNew.GetManagedAudioMedia() == null &&
                                treeNodeNew.GetFirstDescendantWithManagedAudio() == null)
                            {
                                if (IsWaveFormLoading && View != null)
                                {
                                    View.CancelWaveFormLoad(true);
                                }

                                if (!Settings.Default.Audio_DisableSingleWavFileRecord)
                                {
                                    // NOOP
                                }
                                else
                                {
                                    CommandStartRecord.Execute();
                                }
                                return;
                            }
                            else
                            {
                                if (!Settings.Default.Audio_DisableSingleWavFileRecord)
                                {
                                    m_RecordAndContinue_StopSingleFileRecord = true;
                                    CommandStopRecord.Execute();
                                }

                                if (m_DeferredRecordingDataItems != null)
                                {
                                    checkAndAddDeferredRecordingDataItems();

                                    if (IsWaveFormLoading && View != null)
                                    {
                                        View.CancelWaveFormLoad(true);
                                    }

                                    m_UrakawaSession.PerformTreeNodeSelection(treeNodeSelectionNew.Item1, false, treeNodeSelectionNew.Item2);
                                }
                                //CommandPlay.Execute();

                                if (Settings.Default.Audio_Record_OverwriteFollowingAudio)
                                {
                                    CommandSelectAll.Execute();
                                    CommandStartRecord.Execute();
                                }
                            }
                        }
                        else
                        {
#if DEBUG
                            Debugger.Break();
#endif
                        }

                        if (IsMonitoringAlways && !IsMonitoring)
                        {
                            CommandStartMonitor.Execute();
                        }
                        return;
                    }
                }

                if (!Settings.Default.Audio_DisableSingleWavFileRecord)
                {
                    m_RecordAndContinue_StopSingleFileRecord = true;
                    CommandStopRecord.Execute();
                }
            }

            m_RecordAndContinue = false;
            checkAndAddDeferredRecordingDataItems();
            State.Audio.PcmFormatRecordingMonitoring = null;

            if (IsMonitoringAlways && !IsMonitoring)
            {
                CommandStartMonitor.Execute();
            }
        }
Beispiel #2
0
        private void OnAudioPlaybackFinished_(object sender, AudioPlayer.AudioPlaybackFinishEventArgs e)
        {
            bool gotoNext = State.Audio.EndOffsetOfPlayStream == State.Audio.DataLength &&
                            (IsAutoPlay || m_PlayAutoAdvance) &&
                            !IsSelectionSet &&
                            m_UrakawaSession.DocumentProject != null;

            //Logger.Log("AudioPaneViewModel.OnAudioPlaybackFinished", Category.Debug, Priority.Medium);

            if (State.Audio.HasContent)
            {
                SetPlayHeadTimeBypassAutoPlay(State.Audio.EndOffsetOfPlayStream);

                //updateWaveFormPlayHead(time);
            }

            if (gotoNext)
            {
                OnAudioPlaybackFinished_RefreshStatus();

                Tuple <TreeNode, TreeNode> treeNodeSelection = m_UrakawaSession.GetTreeNodeSelection();

                TreeNode nextNode = treeNodeSelection.Item1.GetNextSiblingWithManagedAudio();

next:
                if (nextNode != null)
                {
                    if (Settings.Default.Audio_EnableSkippability && m_UrakawaSession.isTreeNodeSkippable(nextNode))
                    {
                        nextNode = nextNode.GetNextSiblingWithManagedAudio();
                        goto next;
                    }

                    if (IsWaveFormLoading)
                    {
                        if (View != null)
                        {
                            View.CancelWaveFormLoad(true);
                        }
                    }

                    //Logger.Log("-- PublishEvent [TreeNodeSelectedEvent] AudioPaneViewModel.OnAudioPlaybackFinished", Category.Debug, Priority.Medium);

                    //EventAggregator.GetEvent<TreeNodeSelectedEvent>().Publish(nextNode);
                    m_UrakawaSession.PerformTreeNodeSelection(nextNode);
                }
                else
                {
                    m_PlayAutoAdvance = false;

                    if (IsMonitoringAlways)
                    {
                        CommandStartMonitor.Execute();
                    }
                }
            }
            else
            {
                m_PlayAutoAdvance = false;

                if (m_RecordAfterPlayOverwriteSelection > 0) // && State.Selection.SelectionBeginBytePosition == m_RecordAfterPlayOverwriteSelection)
                {
                    SetRecordAfterPlayOverwriteSelection(-1);
                    m_RecordAfterPlayOverwriteSelection = 1;  // hack
                    CommandStartRecord.Execute();
                    m_RecordAfterPlayOverwriteSelection = -1; // hack
                }
                else
                {
                    OnAudioPlaybackFinished_RefreshStatus();

                    if (IsMonitoringAlways)
                    {
                        CommandStartMonitor.Execute();
                    }
                }
            }
        }