예제 #1
0
        private void ribePlay_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            /**
             * if audio_id is not null, then its an old audio file.
             * else, load the azure_blob_audio_id.
             */

            string _FileUrl = string.Empty;

            CTCallLog _row = gvCallLog.GetFocusedRow() as CTCallLog;
            event_followup_log _eftCallLog = null;
            using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection)) {
                _eftCallLog = _efDbContext.event_followup_log.FirstOrDefault(i => i.id == _row.id);
                if (_eftCallLog != null)
                    _efDbContext.Detach(_eftCallLog);
            }

            if (_eftCallLog.is_azure_blob != null && _eftCallLog.is_azure_blob == true)
            {
                if (_eftCallLog.main_uploaded == null)
                {
                    NotificationDialog.Error("Bright Manager", "File is not yet uploaded\nPlease try again in a minute.", _eftCallLog.id);
                    return;
                }
            }

            string audioId = "";
            bool IsNew = true;
            if (!string.IsNullOrEmpty(_eftCallLog.azure_blob_audio_id))
            {
                _FileUrl = string.Format("{0}/{1}.mp3", ConfigManager.AppSettings["AzureBlobStorageNewAudioUrl"].ToString(), _eftCallLog.azure_blob_audio_id.ToString());
                _row.azure_blob_audio_id = _eftCallLog.azure_blob_audio_id;
                audioId = _eftCallLog.azure_blob_audio_id;
            }
            else
            {
                _FileUrl = string.Format("{0}/{1}_.mp3", ConfigManager.AppSettings["AzureBlobStorageOldAudioUrl"].ToString(), _eftCallLog.audio_id.ToString());
                audioId = _eftCallLog.audio_id.ToString();
                IsNew = false;
            }

            WaitDialog.Show("Loading audio stream ...");
            CallLogPlayer _Player = new CallLogPlayer(_eftCallLog.id, audioId, _FileUrl, true, IsNew);
            if (!_Player.IsDisposed && _Player.CanBePlayed) {
                WaitDialog.Close();
                _Player.Show(this);
            }
            else
                WaitDialog.Close();

            #region Old Code
            //Guid audioId = Guid.Parse(gvCallLog.GetFocusedRowCellValue("audio_file").ToString());
            //var commonFolder = new CommonApplicationData("BrightVision", "BrightSales");
            ////string filePathTmpWav = String.Format(@"{0}\tmpwav\{1}_.wav", commonFolder.ApplicationFolderPath, audioId);
            //string filePathCachWav = String.Format(@"{0}\cachewav\{1}_.wav", commonFolder.ApplicationFolderPath, audioId);
            //string filePathCachWav2 = String.Format(@"{0}\cachewav\{1}_.mp3", commonFolder.ApplicationFolderPath, audioId);
            //object objMainUploaded = gvCallLog.GetFocusedRowCellValue("main_uploaded");
            //bool mainUploaded = false;
            ////bool isTmWavExist = File.Exists(filePathTmpWav);
            //bool isCacheWavExist = File.Exists(filePathCachWav);
            //bool isCacheWav2Exist = File.Exists(filePathCachWav2);
            //if (objMainUploaded != null)
            //    mainUploaded = bool.Parse(objMainUploaded.ToString());

            //if (isCacheWavExist)
            //    PlayAudio(filePathCachWav);
            //else if (isCacheWav2Exist)
            //    PlayAudio(filePathCachWav2);
            //else if (mainUploaded)
            //{
            //    if (_player != null)
            //    {

            //        _player = null;
            //    }

            //    WaitDialog.Show("Downloading audio files....");
            //    Guid audioID = Guid.Parse(gvCallLog.GetFocusedRowCellValue("audio_file").ToString());
            //    string fileServerUrl = FileManagerUtility.GetServerUrl(audioID);
            //    /*if(!ManagerApplicationFacade.WebDavFile.IsFileExist(fileServerUrl, audioID.ToString()))
            //    {
            //        MessageBox.Show("Audio file does not exist. Please contact administrator.", "Download audio failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //        return;
            //    }*/

            //    string m_AudioFileUrl = ManagerApplicationFacade.WebDavFile.AudioToCacheFolder(fileServerUrl);
            //    if (string.IsNullOrEmpty(m_AudioFileUrl))
            //    {
            //        MessageBox.Show("Can't download audio file. Please contact administrator.", "Download audio failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //        return;
            //    }
            //    Thread.Sleep(2000);
            //    WaitDialog.Close();
            //    PlayAudio(m_AudioFileUrl);
            //}
            #endregion
        }
예제 #2
0
 private void PlayAudio(string url)
 {
     FileInfo info = new FileInfo(url);
     if (info.Length == 0)
         MessageBox.Show("Can't play audio. Audio file don't have content.", "Can't play audio", MessageBoxButtons.OK, MessageBoxIcon.Information);
     else
     {
         _player = new CallLogPlayer(url);
         if (!_player.IsDisposed)
         {
             //_player.PlayAudio();
             _player.Show(this);
         }
         //_player.Stop();
     }
 }