- Using QSoundEffect, you've written a utility for a call center that allows them to review recorded phone calls. They're moving to a new phone system that stores the audio calls as MP3 files. Do you need to make any changes to your utility?
Yes. You'll need to use QMediaPlayer instead of QSoundEffect, or write a layer to decode the MP3 to WAV, because QSoundEffect cannot play compressed audio.
- cool_songs is a Python list containing path strings to your favorite songs. What do you need to do to play these songs back in a random order?
You need to convert the paths into QUrl objects, add them to QMediaPlaylist, set playbackMode to Random, then pass it to QMediaPlayer. The code looks like this:
playlist = qtmm.QMediaPlaylist()
for song in cool_songs:
url = qtc.QUrl.fromLocalFile(song)
content = qtmm.QMediaContent(url)
playlist.addMedia...