private void ribePlay_ButtonClick(object sender, ButtonPressedEventArgs e) { if (m_BrightSalesProperty.CommonProperty.OnCallMode || !m_BrightSalesProperty.CommonProperty.CallLogSaved) { NotificationDialog.Information("Bright Sales", "A call is currently in progress or a pending call log needs to be saved first."); return; } /** * if audio_id is not null, then its an old audio file. * else, load the azure_blob_audio_id. */ string _FileUrl = string.Empty; CTScEventAndFollowUpLog _row = gvEventLog.GetFocusedRow() as CTScEventAndFollowUpLog; 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 Sales", "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; _row.audio_id = null; 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; } //if (!string.IsNullOrEmpty(_eftCallLog.audio_id.ToString())) { // _FileUrl = "https://lii.blob.core.windows.net/old/0a4b23f7-eab8-4043-ad84-36b4b5d23f1e_.mp3"; // //_FileUrl = string.Format("{0}/{1}_.mp3", ConfigManager.AppSettings["AzureBlobStorageOldAudioUrl"].ToString(), _eftCallLog.audio_id.ToString()); //} //else // _FileUrl = string.Format("{0}/{1}.mp3", ConfigManager.AppSettings["AzureBlobStorageNewAudioUrl"].ToString(), _eftCallLog.azure_blob_audio_id.ToString()); 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(); //BrightVision.VlcMediaPlayer.UI.FrmVlcMediaPlayer _Player = new BrightVision.VlcMediaPlayer.UI.FrmVlcMediaPlayer("https://lii.blob.core.windows.net/old/0a4b23f7-eab8-4043-ad84-36b4b5d23f1e_.mp3"); //_Player.ShowDialog(this.ParentForm); /** / Guid audioId = Guid.Parse(gvEventLog.GetFocusedRowCellValue("audio_id").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 = gvEventLog.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(gvEventLog.GetFocusedRowCellValue("audio_id").ToString()); string fileServerUrl = FileManagerUtility.GetServerUrl(audioID); string m_AudioFileUrl = BrightSalesFacade.WebDavFile.AudioToCacheFolder(fileServerUrl); if (string.IsNullOrEmpty(m_AudioFileUrl)) { NotificationDialog.Error("Bright Sales", "Cannot download audio file. Please contact administrator."); return; } Thread.Sleep(2000); WaitDialog.Close(); PlayAudio(m_AudioFileUrl); } /**/ }
private void PlayAudio(string url) { FileInfo info = new FileInfo(url); if (info.Length == 0) NotificationDialog.Information("Bright Sales", "Cannot play audio. Audio file don't have content."); else { _player = new CallLogPlayer(url); if (!_player.IsDisposed) { //_player.PlayAudio(); _player.Show(this); } //_player.Stop(); } }