mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
play audio
This commit is contained in:
parent
a9a72d9d72
commit
cd70f33ee6
@ -9,6 +9,10 @@
|
|||||||
#include <common/path_util.h>
|
#include <common/path_util.h>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
|
#ifdef ENABLE_QT_GUI
|
||||||
|
#include <qt_gui/background_music_player.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
@ -78,6 +82,14 @@ TrophyUI::TrophyUI(const std::filesystem::path& trophyIconPath, const std::strin
|
|||||||
trophy_type_icon = RefCountedTexture::DecodePngTexture(imgdata);
|
trophy_type_icon = RefCountedTexture::DecodePngTexture(imgdata);
|
||||||
|
|
||||||
AddLayer(this);
|
AddLayer(this);
|
||||||
|
|
||||||
|
#ifdef ENABLE_QT_GUI
|
||||||
|
QString musicPath = QString::fromStdString(CustomTrophy_Dir.string() + "/trophy.mp3");
|
||||||
|
if (fs::exists(musicPath.toStdString())) {
|
||||||
|
BackgroundMusicPlayer::getInstance().setVolume(100);
|
||||||
|
BackgroundMusicPlayer::getInstance().playMusic(musicPath, false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TrophyUI::~TrophyUI() {
|
TrophyUI::~TrophyUI() {
|
||||||
|
@ -7,7 +7,6 @@ BackgroundMusicPlayer::BackgroundMusicPlayer(QObject* parent) : QObject(parent)
|
|||||||
m_mediaPlayer = new QMediaPlayer(this);
|
m_mediaPlayer = new QMediaPlayer(this);
|
||||||
m_audioOutput = new QAudioOutput(this);
|
m_audioOutput = new QAudioOutput(this);
|
||||||
m_mediaPlayer->setAudioOutput(m_audioOutput);
|
m_mediaPlayer->setAudioOutput(m_audioOutput);
|
||||||
m_mediaPlayer->setLoops(QMediaPlayer::Infinite);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackgroundMusicPlayer::setVolume(int volume) {
|
void BackgroundMusicPlayer::setVolume(int volume) {
|
||||||
@ -16,7 +15,7 @@ void BackgroundMusicPlayer::setVolume(int volume) {
|
|||||||
m_audioOutput->setVolume(linearVolume);
|
m_audioOutput->setVolume(linearVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackgroundMusicPlayer::playMusic(const QString& snd0path) {
|
void BackgroundMusicPlayer::playMusic(const QString& snd0path, bool loops) {
|
||||||
if (snd0path.isEmpty()) {
|
if (snd0path.isEmpty()) {
|
||||||
stopMusic();
|
stopMusic();
|
||||||
return;
|
return;
|
||||||
@ -28,6 +27,12 @@ void BackgroundMusicPlayer::playMusic(const QString& snd0path) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (loops) {
|
||||||
|
m_mediaPlayer->setLoops(QMediaPlayer::Infinite);
|
||||||
|
} else {
|
||||||
|
m_mediaPlayer->setLoops(1);
|
||||||
|
}
|
||||||
|
|
||||||
m_currentMusic = newMusic;
|
m_currentMusic = newMusic;
|
||||||
m_mediaPlayer->setSource(newMusic);
|
m_mediaPlayer->setSource(newMusic);
|
||||||
m_mediaPlayer->play();
|
m_mediaPlayer->play();
|
||||||
|
@ -17,7 +17,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setVolume(int volume);
|
void setVolume(int volume);
|
||||||
void playMusic(const QString& snd0path);
|
void playMusic(const QString& snd0path, bool loops = true);
|
||||||
void stopMusic();
|
void stopMusic();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -609,7 +609,7 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) {
|
|||||||
|
|
||||||
//User
|
//User
|
||||||
if (elementName == "OpenCustomTrophyLocationButton") {
|
if (elementName == "OpenCustomTrophyLocationButton") {
|
||||||
text = tr("Open custom trophy images folder:\\nIt is possible to add custom images to the trophies.\\nAdd the files to custom_trophy with the following names:\\nbronze.png, gold.png, platinum.png, silver.png");
|
text = tr("Open the custom trophy images/sounds folder:\\nYou can add custom images to the trophies and an audio.\\nAdd the files to custom_trophy with the following names:\\nthophy.mp3, bronze.png, gold.png, platinum.png, silver.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
|
@ -1294,7 +1294,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="OpenCustomTrophyLocationButton">
|
<widget class="QPushButton" name="OpenCustomTrophyLocationButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Open custom trophy images folder</string>
|
<string>Open the custom trophy images/sounds folder</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -1312,8 +1312,8 @@
|
|||||||
<translation>Trophy</translation>
|
<translation>Trophy</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Open custom trophy images folder</source>
|
<source>Open the custom trophy images/sounds folder</source>
|
||||||
<translation>Open custom trophy images folder</translation>
|
<translation>Open the custom trophy images/sounds folder</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Logger</source>
|
<source>Logger</source>
|
||||||
@ -1616,8 +1616,8 @@
|
|||||||
<translation>Update Compatibility Database:\nImmediately update the compatibility database.</translation>
|
<translation>Update Compatibility Database:\nImmediately update the compatibility database.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Open custom trophy images folder:\nIt is possible to add custom images to the trophies.\nAdd the files to custom_trophy with the following names:\nbronze.png, gold.png, platinum.png, silver.png</source>
|
<source>Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\nthophy.mp3, bronze.png, gold.png, platinum.png, silver.png</source>
|
||||||
<translation>Open custom trophy images folder:\nIt is possible to add custom images to the trophies.\nAdd the files to custom_trophy with the following names:\nbronze.png, gold.png, platinum.png, silver.png</translation>
|
<translation>Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\nthophy.mp3, bronze.png, gold.png, platinum.png, silver.png</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Never</source>
|
<source>Never</source>
|
||||||
|
Loading…
Reference in New Issue
Block a user