18 #include <Phonon/MediaObject>
20 #include <keduvocexpression.h>
25 using namespace Editor;
30 m_currentTranslation = -1;
33 connect(audioUrlRequester, SIGNAL(textChanged(
const QString&)), SLOT(slotAudioFileChanged(
const QString&)));
34 connect(playButton, SIGNAL(clicked()), SLOT(playAudio()));
37 playButton->setEnabled(
false);
38 playButton->setIcon(KIcon(
"media-playback-start"));
39 recordButton->setVisible(
false);
42 audioUrlRequester->setEnabled(
false);
47 m_currentTranslation = translation;
51 recordButton->setEnabled(
true);
52 audioUrlRequester->setEnabled(
true);
53 audioUrlRequester->setUrl(m_entry->translation(m_currentTranslation)->soundUrl().toLocalFile());
55 recordButton->setEnabled(
false);
56 audioUrlRequester->setEnabled(
false);
58 if (m_player->state() == Phonon::PlayingState) {
59 playButton->setEnabled(
true);
61 playButton->setEnabled(
false);
64 audioUrlRequester->clear();
68 void AudioWidget::slotAudioFileChanged(
const QString & url)
71 m_entry->translation(m_currentTranslation)->setSoundUrl( KUrl(url) );
73 playButton->setEnabled(!url.isEmpty());
76 void AudioWidget::playAudio()
78 KUrl soundFile = m_entry->translation(m_currentTranslation)->soundUrl();
82 m_player = Phonon::createPlayer(Phonon::NotificationCategory, soundFile);
83 m_player->setParent(
this);
84 connect(m_player, SIGNAL(finished()), SLOT(slotPlaybackFinished()));
86 if (m_player->state() == Phonon::PlayingState) {
88 slotPlaybackFinished();
91 m_player->setCurrentSource(soundFile);
93 playButton->setIcon(KIcon(
"media-playback-stop"));
104 void AudioWidget::slotPlaybackFinished()
106 playButton->setIcon(KIcon(
"media-playback-start"));
107 playButton->setEnabled(!audioUrlRequester->url().isEmpty());
110 #include "audiowidget.moc"