X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FfrmContactEditor-Sound.cpp;h=369238c227882c8ea1973bae2151d21fd17255c9;hb=bfe817b5bfae33a1eb666c463643ec119cd1d66d;hp=ba1a0c95b9f942aeb19e5c0e8c98a065bc4fbb0a;hpb=f6677e923dd53b8adb640db4cd8ede54182e12c2;p=xestiaab%2F.git
diff --git a/source/contacteditor/frmContactEditor-Sound.cpp b/source/contacteditor/frmContactEditor-Sound.cpp
index ba1a0c9..369238c 100644
--- a/source/contacteditor/frmContactEditor-Sound.cpp
+++ b/source/contacteditor/frmContactEditor-Sound.cpp
@@ -17,10 +17,6 @@
// with Xestia Address Book. If not, see
#include "frmContactEditor.h"
-#include "frmContactEditorSound.h"
-#include "../common/base64.h"
-#include
-#include
void frmContactEditor::AddSound( wxCommandEvent& event )
{
@@ -54,7 +50,7 @@ void frmContactEditor::ModifySound( wxCommandEvent& event )
long longSelected = -1;
int intSelectedData = 0;
- if (!GetSelectedItem(lboSounds,
+ if (lboSounds->GetItemCount() == 0 || !GetSelectedItem(lboSounds,
&longSelected,
&intSelectedData)){
return;
@@ -87,7 +83,7 @@ void frmContactEditor::DeleteSound( wxCommandEvent& event )
long longSelected = -1;
int intSelectedData = 0;
- if (!GetSelectedItem(lboSounds,
+ if (lboSounds->GetItemCount() == 0 || !GetSelectedItem(lboSounds,
&longSelected,
&intSelectedData)){
return;
@@ -107,7 +103,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.
@@ -120,17 +116,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();
}
@@ -142,20 +139,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);
@@ -174,14 +179,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;
@@ -195,7 +201,7 @@ void frmContactEditor::SaveSound( wxCommandEvent &event )
long longSelected = -1;
int intSelectedData = 0;
- if (!GetSelectedItem(lboSounds,
+ if (lboSounds->GetItemCount() == 0 || !GetSelectedItem(lboSounds,
&longSelected,
&intSelectedData)){