X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FfrmContactEditor-Sound.cpp;h=99febcc62d47ac3711079160f1d348e7f8380bc8;hb=f69e09d827e06435ea94bb73aa71ab5f9d5c035b;hp=6138d97eaca9bef72628cb48b8a943411be501af;hpb=e30eba8679da6f7db7132efe79af6cb49c52750e;p=xestiaab%2F.git diff --git a/source/contacteditor/frmContactEditor-Sound.cpp b/source/contacteditor/frmContactEditor-Sound.cpp index 6138d97..99febcc 100644 --- a/source/contacteditor/frmContactEditor-Sound.cpp +++ b/source/contacteditor/frmContactEditor-Sound.cpp @@ -17,19 +17,14 @@ // with Xestia Address Book. If not, see #include "frmContactEditor.h" -#include "frmContactEditorSound.h" -#include "../common/base64.h" -#include -#include void frmContactEditor::AddSound( wxCommandEvent& event ) { - int intResult = 0; - + // Bring up a form to add sound. + frmContactEditorSound *frameCESound = new frmContactEditorSound ( this ); frameCESound->SetEditorMode(FALSE); - intResult = GetLastInt(&ContactEditorData.SoundsList); frameCESound->SetupPointers(&ContactEditorData.SoundsList, &ContactEditorData.SoundsListAltID, &ContactEditorData.SoundsListPID, @@ -44,16 +39,19 @@ void frmContactEditor::AddSound( wxCommandEvent& event ) frameCESound->ShowModal(); delete frameCESound; frameCESound = NULL; - + intValueSeek++; + } void frmContactEditor::ModifySound( wxCommandEvent& event ) { + // Bring up a form to modify sound. + long longSelected = -1; int intSelectedData = 0; - if (!GetSelectedItem(lboSounds, + if (lboSounds->GetItemCount() == 0 || !GetSelectedItem(lboSounds, &longSelected, &intSelectedData)){ return; @@ -81,10 +79,12 @@ void frmContactEditor::ModifySound( wxCommandEvent& event ) void frmContactEditor::DeleteSound( wxCommandEvent& event ) { + // Bring up a form to delete sound. + long longSelected = -1; int intSelectedData = 0; - if (!GetSelectedItem(lboSounds, + if (lboSounds->GetItemCount() == 0 || !GetSelectedItem(lboSounds, &longSelected, &intSelectedData)){ return; @@ -102,7 +102,9 @@ void frmContactEditor::DeleteSound( wxCommandEvent& event ) void frmContactEditor::PlaySoundDetach() { - if (!AudioStreamPlayback.openFromMemory(base64dec.c_str(), base64declen)){ + // Play the sound and detach. + + if (!AudioStreamPlaybackPointer->openFromMemory(base64dec.c_str(), base64declen)){ // Can't load file. We must flee... // Also show an error message too. @@ -114,66 +116,52 @@ void frmContactEditor::PlaySoundDetach() } btnStop->Enable(); + + AudioStreamPlaybackPointer->play(); - //AudioStreamPlayback.setbuffer(AudioBuffer); - AudioStreamPlayback.play(); - - /*timespec n1, n2; - - n1.tv_sec = 0; - n1.tv_nsec = 100000000L;*/ - - //while (TimeA != TimeB){ - while (AudioStreamPlayback.getStatus() == sf::SoundSource::Playing){ + while (AudioStreamPlaybackPointer->getStatus() == sf::SoundSource::Playing){ // We poll this every 100ms in order to conserve CPU usage. - SleepFor(100000000); + SleepFor(10000000); } - + btnStop->Disable(); + btnPlay->Enable(); } void frmContactEditor::PlaySound( wxCommandEvent& event ) { - //sf::Music *AudioPlayback = new sf::Music; - //AudioStream *AudioStreamPlayback = new AudioStream; - //sf::SoundBuffer *AudioBuffer = new sf::SoundBuffer; - - //sf::Sound *AudioPlayback = new sf::Sound; - - //delete(AudioPlayback); - - //delete(AudioPlayback); - //delete(AudioStreamPlayback); - //delete(AudioBuffer); - - //AudioPlayback = NULL; - //AudioStreamPlayback = NULL; - //AudioBuffer = NULL; - - //return; + // Play the sound. long longSelected = -1; int intSelectedData = 0; + if (AudioStreamPlaybackPointer == nullptr){ + + AudioStreamPlaybackPointer = new AudioStream; + + } + // Check if sound is still being played and if it is, stop it. - if (AudioStreamPlayback.getStatus() == sf::SoundSource::Playing){ + if (AudioStreamPlaybackPointer->getStatus() == sf::SoundSource::Playing){ - AudioStreamPlayback.stop(); + AudioStreamPlaybackPointer->stop(); } - if (!GetSelectedItem(lboSounds, + if (lboSounds->GetItemCount() == 0 || !GetSelectedItem(lboSounds, &longSelected, &intSelectedData)){ return; } - + + btnPlay->Disable(); + std::map::iterator initier; initier = ContactEditorData.SoundsList.find(intSelectedData); @@ -190,14 +178,17 @@ void frmContactEditor::PlaySound( wxCommandEvent& event ) void frmContactEditor::StopSound( wxCommandEvent& event ) { - - if (AudioStreamPlayback.getStatus() == sf::SoundSource::Playing){ - - AudioStreamPlayback.stop(); + + // Stop the sound. + + if (AudioStreamPlaybackPointer != nullptr && AudioStreamPlaybackPointer->getStatus() == sf::SoundSource::Playing){ + AudioStreamPlaybackPointer->stop(); + } btnStop->Disable(); + btnPlay->Enable(); return; @@ -206,10 +197,12 @@ void frmContactEditor::StopSound( wxCommandEvent& event ) void frmContactEditor::SaveSound( wxCommandEvent &event ) { + // Save the sound. + long longSelected = -1; int intSelectedData = 0; - if (!GetSelectedItem(lboSounds, + if (lboSounds->GetItemCount() == 0 || !GetSelectedItem(lboSounds, &longSelected, &intSelectedData)){