示例#1
0
        // Event hendlers for incoming call
        #region IncomingCallEvents

        private void btnAccept_Click(object sender, RoutedEventArgs e)
        {
            if (this.call != null)
            {
                // resume call
                if (this.call.State == Call.CallState.Hold)
                {
                    // discard blur effect to infoPanel
                    if (borderCallNotification.BitmapEffect != null)
                    {
                        borderCallNotification.BitmapEffect = null;
                        borderCallNotification.Background   = null;
                    }
                    // resume
                    Softphone.ResumeCall(this.call);

                    // Play notification
                    LocalAudioPlayer.PlaySound(Properties.Resources.incoming_chat);
                }
                else
                {
                    // receive call
                    Softphone.ReceiveCall(this.call);
                }
            }
        }
示例#2
0
        public void Volume_NoSongLoadedAndVolumeIsSet_ReturnsSettedVolume()
        {
            var audioPlayer = new LocalAudioPlayer(Helpers.SetupSongMock())
            {
                Volume = 0.5f
            };

            Assert.AreEqual(0.5f, audioPlayer.Volume);
        }
示例#3
0
        private void CallTransferTo(string transferNumber)
        {
            // Если введеный номер не правильный или [object]call == nil -> выход
            if (this.call == null || string.IsNullOrEmpty(transferNumber))
            {
                return;
            }
#warning MakeTransferNatieve
            Softphone.TransferCall(this.call, transferNumber);

            LocalAudioPlayer.PlaySound(Properties.Resources.notification_translate);
        }
示例#4
0
        private void CleanUp()
        {
            if (bgPlayWorker != null)
            {
                this.bgPlayWorker.DoWork             -= new System.ComponentModel.DoWorkEventHandler(this.bgPlayWorker_DoWork);
                this.bgPlayWorker.RunWorkerCompleted -= new System.ComponentModel.RunWorkerCompletedEventHandler(this.bgPlayWorker_RunWorkerCompleted);
                bgPlayWorker.Dispose();
                bgPlayWorker = null;
            }
            if (waitHandle != null)
            {
                waitHandle.Close();
                //waitHandle.Dispose();
                waitHandle = null;
            }

            if (audioPlayer != null)
            {
                audioPlayer.StopPlayback();
                audioPlayer.Dispose();
                audioPlayer = null;
            }
            if (aTimer != null)
            {
                aTimer.Elapsed -= OnTimedEvent;
                aTimer.Dispose();
                aTimer = null;
            }
            if (marqueeLbl != null)
            {
                marqueeLbl.Dispose();
            }
            plWnd.CloseButtonClicked        -= plWnd_CloseButtonClicked;
            plWnd.PlaylistItemDoubleClicked -= plWnd_PlaylistItemDoubleClicked;
            plWnd.PlaylistLoaded            -= plWnd_PlaylistLoaded;
            plWnd.PlaylistCleared           -= plWnd_PlaylistCleared;
            plWnd.Close();
            plWnd.Dispose();

            if (pnTrackInfo != null)
            {
                pnTrackInfo.Dispose();
            }

            if (gkHook != null)
            {
                gkHook.KeyPressed -= OnKeyPressed;
                gkHook.Dispose();
            }
        }
示例#5
0
        /// <summary>
        /// loads tag information from audio file
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="player"></param>
        /// <param name="IsMp3"></param>
        public void LoadTagInfo(string fileName, LocalAudioPlayer player, bool IsMp3)
        {
            this.player   = player;
            this.fileName = fileName;

            pictBox.WaitOnLoad     = false;
            pictBox.LoadCompleted += LoadCompleted;

            if (IsMp3)
            {
                LoadMp3Information();
            }
            else
            {
                cMenu.Enabled = false;

                LoadVorbisInformation();
            }
        }
示例#6
0
        public void TotalTime_NoSongLoaded_ReturnsTimeSpanZero()
        {
            var audioPlayer = new LocalAudioPlayer(Helpers.SetupSongMock());

            Assert.AreEqual(TimeSpan.Zero, audioPlayer.TotalTime);
        }
示例#7
0
        public void PlaybackState_NoSongLoaded_ReturnsNone()
        {
            var audioPlayer = new LocalAudioPlayer(Helpers.SetupSongMock());

            Assert.AreEqual(AudioPlayerState.None, audioPlayer.PlaybackState);
        }
示例#8
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            if (mAudioFile == null)
            {
                Thread t = new Thread(delegate()
                {
                    bool hasSelFile = SelectInputFile();
                    if (hasSelFile)
                    {
                        InitPlayer();
                        InitBgWorker();
                        StartPlaybackThread();
                        //if (audioPlayer != null)
                        //    audioPlayer.PlaybackStopType = PlaybackStopTypes.PlaybackStoppedReachingEndOfFile;
                        userStopped         = false;
                        isSingleFilePlaying = true;
                    }
                });
                t.Start();
            }
            else
            {
                try
                {
                    if (audioPlayer == null)
                    {
                        audioPlayer =
                            new LocalAudioPlayer(mAudioFile, GetSelectedOutputDriver());
                        audioPlayer.PlaybackStopType = PlaybackStopTypes.PlaybackStoppedReachingEndOfFile;
                        //audioPlayer.PlaybackPaused += audioPlayer_PlaybackPaused;
                        audioPlayer.PlaybackResumed += audioPlayer_PlaybackResumed;
                        //audioPlayer.PlaybackStopped += audioPlayer_PlaybackStopped;

                        if (!IsPlaylistRunning)
                        {
                            currentAudioFile = new AudioFileInfo(Path.GetFileName(mAudioFile), mAudioFile);
                        }

                        Action action = () =>
                        {
                            if (tbVolume.Value != VOL_INIT * 100)
                            {
                                audioPlayer.SetVolume((float)tbVolume.Value / 100f);
                            }
                            else
                            {
                                audioPlayer.SetVolume(VOL_INIT);
                            }
                        };
                        Invoke(action);

                        StartPlaybackThread();
                    }
                    else
                    {
                        if (aTimer != null && !aTimer.Enabled)
                        {
                            aTimer.Enabled = true;
                            aTimer.Start();
                        }
                        StartPlaybackThread();
                        audioPlayer.PlaybackStopType = PlaybackStopTypes.PlaybackStoppedReachingEndOfFile;
                    }
                }
                catch (Exception)
                {
                }
                userStopped = false;
            }
        }
示例#9
0
        /// <summary>
        /// init the audio player
        /// </summary>
        public void InitPlayer(bool dispose = true, PlaybackStopTypes pbStopType = PlaybackStopTypes.PlaybackStoppedReachingEndOfFile)
        {
            if (aTimer.Enabled)
            {
                aTimer.Stop();
                aTimer.Enabled = false;
            }

            Action action;

            //action = () =>
            //    {
            try
            {
                if (audioPlayer != null)
                {
                    //waitHandle.Set();
                    if (audioPlayer.IsPlaying() || audioPlayer.IsPaused())
                    {
                        audioPlayer.StopPlayback();
                    }
                    while (isWaitingHandle)
                    {
                    }
                    audioPlayer.PlaybackResumed -= audioPlayer_PlaybackResumed;
                    //audioPlayer.PlaybackStopped -= audioPlayer_PlaybackStopped;
                    if (dispose)
                    {
                        audioPlayer.Dispose();
                        audioPlayer = null;
                    }
                }
            }
            catch (Exception)
            {
                //throw;
            }
            //    };
            //Invoke(action);
            try
            {
                //if (audioPlayer == null)

                audioPlayer =
                    new LocalAudioPlayer(mAudioFile, GetSelectedOutputDriver());
                audioPlayer.PlaybackStopType = pbStopType;
                //audioPlayer.PlaybackPaused += audioPlayer_PlaybackPaused;
                audioPlayer.PlaybackResumed += audioPlayer_PlaybackResumed;
                //audioPlayer.PlaybackStopped += audioPlayer_PlaybackStopped;
                if (!IsPlaylistRunning)
                {
                    currentAudioFile = new AudioFileInfo(Path.GetFileName(mAudioFile), mAudioFile);
                }
            }
            catch (Exception)
            {
                action = () => MessageBox.Show(this, string.Format("Cannot load file '{0}'", mAudioFile));
                Invoke(action);
            }
            if (audioPlayer != null)
            {
                action = () =>
                {
                    if (tbVolume.Value != VOL_INIT * 100)
                    {
                        audioPlayer.SetVolume((float)tbVolume.Value / 100f);
                    }
                    else
                    {
                        audioPlayer.SetVolume(VOL_INIT);
                    }
                };
                tbVolume.Invoke(action);
                action = () => lblTotalTime.Text = Utils.FormatTimeSpan(audioPlayer.GetTotalTime());
                lblTotalTime.Invoke(action);
                action = () =>
                {
                    tbAudioPos.Value   = 0;
                    tbAudioPos.Maximum = (int)(audioPlayer.GetTotalTime().Minutes) * 60
                                         + audioPlayer.GetTotalTime().Seconds;
                    if (tbAudioPos.Maximum > 0)
                    {
                        tbAudioPos.Enabled = true;
                    }
                    else
                    {
                        tbAudioPos.Enabled = false;
                    }
                };
                tbAudioPos.Invoke(action);
                action = () =>
                {
                    UpdateMarquee();
                };
                Invoke(action);
            }
        }