X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FfrmContactEditor-Sound.cpp;h=99febcc62d47ac3711079160f1d348e7f8380bc8;hb=bac054ea5eda94fe663d8b1a7c680ae80de8075c;hp=cda5036d834069b01ee753878bcfbe290e085a84;hpb=8a55f4cbca8e7cfd70c1f0ac08e8cf157fca0794;p=xestiaab%2F.git diff --git a/source/contacteditor/frmContactEditor-Sound.cpp b/source/contacteditor/frmContactEditor-Sound.cpp index cda5036..99febcc 100644 --- a/source/contacteditor/frmContactEditor-Sound.cpp +++ b/source/contacteditor/frmContactEditor-Sound.cpp @@ -17,21 +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 ) { // Bring up a form to add sound. - - int intResult = 0; - + frmContactEditorSound *frameCESound = new frmContactEditorSound ( this ); frameCESound->SetEditorMode(FALSE); - intResult = GetLastInt(&ContactEditorData.SoundsList); frameCESound->SetupPointers(&ContactEditorData.SoundsList, &ContactEditorData.SoundsListAltID, &ContactEditorData.SoundsListPID, @@ -46,7 +39,8 @@ void frmContactEditor::AddSound( wxCommandEvent& event ) frameCESound->ShowModal(); delete frameCESound; frameCESound = NULL; - + intValueSeek++; + } void frmContactEditor::ModifySound( wxCommandEvent& event ) @@ -57,7 +51,7 @@ void frmContactEditor::ModifySound( wxCommandEvent& event ) long longSelected = -1; int intSelectedData = 0; - if (!GetSelectedItem(lboSounds, + if (lboSounds->GetItemCount() == 0 || !GetSelectedItem(lboSounds, &longSelected, &intSelectedData)){ return; @@ -90,7 +84,7 @@ void frmContactEditor::DeleteSound( wxCommandEvent& event ) long longSelected = -1; int intSelectedData = 0; - if (!GetSelectedItem(lboSounds, + if (lboSounds->GetItemCount() == 0 || !GetSelectedItem(lboSounds, &longSelected, &intSelectedData)){ return; @@ -110,7 +104,7 @@ void frmContactEditor::PlaySoundDetach() // Play the sound and detach. - if (!AudioStreamPlayback.openFromMemory(base64dec.c_str(), base64declen)){ + if (!AudioStreamPlaybackPointer->openFromMemory(base64dec.c_str(), base64declen)){ // Can't load file. We must flee... // Also show an error message too. @@ -123,17 +117,18 @@ void frmContactEditor::PlaySoundDetach() btnStop->Enable(); - AudioStreamPlayback.play(); + AudioStreamPlaybackPointer->play(); - 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(); } @@ -145,20 +140,28 @@ void frmContactEditor::PlaySound( wxCommandEvent& event ) 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); @@ -177,14 +180,15 @@ void frmContactEditor::StopSound( wxCommandEvent& event ) { // Stop the sound. - - if (AudioStreamPlayback.getStatus() == sf::SoundSource::Playing){ - - AudioStreamPlayback.stop(); + + if (AudioStreamPlaybackPointer != nullptr && AudioStreamPlaybackPointer->getStatus() == sf::SoundSource::Playing){ + AudioStreamPlaybackPointer->stop(); + } btnStop->Disable(); + btnPlay->Enable(); return; @@ -198,7 +202,7 @@ void frmContactEditor::SaveSound( wxCommandEvent &event ) long longSelected = -1; int intSelectedData = 0; - if (!GetSelectedItem(lboSounds, + if (lboSounds->GetItemCount() == 0 || !GetSelectedItem(lboSounds, &longSelected, &intSelectedData)){