I'm using Qt Creator to design a game, trying to add a simple audio player to play whenever the function is called. The game will be used on another computer but the entire Snake directory will be moved so I'm wondering the best way to code this so that it can be played anywhere with the audio.
The mp3 is located in the sub directory "scripts/byte.mp3" but I'm wondering if I'm misusing the URL pathing. I've tried "./scripts/byte.mp3" as well as "//scripts/byte.mp3" but it just can't seem to find the file unless I do the entire path. Wondering what is the right way to code it to find the file.
void GLWidget::playAudio()
{
audioPlayer->setMedia(QUrl::fromLocalFile("C:/Users/Jim/Documents/Snake/sounds/byte.mp3"));
audioPlayer->setVolume(50);
audioPlayer->play();
}