Results 1 to 1 of 1

Thread: Phonon, play sound on key press

  1. #1
    Join Date
    Jul 2010
    Posts
    16
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Phonon, play sound on key press

    Hi,
    I need to play a sound when a key on keyboard is pressed, I have this:
    Qt Code:
    1. Phonon::MediaObject *clickObject = new Phonon::MediaObject(this);
    2. clickObject->setCurrentSource(Phonon::MediaSource("Click/sound.wav");
    3. Phonon::AudioOutput *clickOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    4. Phonon::createPath(clickObject, clickOutput);
    To copy to clipboard, switch view to plain text mode 

    and

    Qt Code:
    1. void MainWindow::keyPressEvent(QKeyEvent *event)
    2. {
    3. clickObject->play();
    4. }
    To copy to clipboard, switch view to plain text mode 

    but no sound is played?
    Where am I wrong?
    Thanks.
    Last edited by ale6111; 1st August 2010 at 19:10.

Similar Threads

  1. How to play a sound from a resource file?
    By Asperamanca in forum Newbie
    Replies: 3
    Last Post: 21st July 2010, 17:28
  2. Play .amr sound
    By ahmdsd_ostora in forum Qt Programming
    Replies: 3
    Last Post: 17th July 2010, 15:34
  3. Replies: 6
    Last Post: 23rd December 2009, 10:45
  4. Phonon Cannot Play Sound (without Error)
    By padawan in forum Qt Programming
    Replies: 5
    Last Post: 16th September 2009, 15:17
  5. MP3 Sound / OGG Sound Play on GUI
    By patrik08 in forum Newbie
    Replies: 3
    Last Post: 1st September 2006, 19:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.