Commit 0b554f40 authored by Aman Kumar Gupta's avatar Aman Kumar Gupta Committed by Johnny Jazeix
Browse files

background_music: software needs to be restarted to enable background music if...

background_music: software needs to be restarted to enable background music if it was disabled when launched.
parent 2fd38088
......@@ -30,6 +30,7 @@ ActivityBase {
id: activity
property int speedSetting: 5
property int timerNormalInterval: (13500 / speedSetting)
isMusicalActivity: true
onStart: focus = true
onStop: {}
......
......@@ -140,14 +140,6 @@ Item {
*/
property Loading loading
/**
* type: bool
* This variable stores if the activity is a musical activity.
*
* If it is a musical activity and the audioEffects is disabled, we temporarily unmute the GCSfx audioEffects for that activity and mute again on exiting it in main.qml.
*/
property bool isMusicalActivity: false
/**
* Emitted when the user wants to return to the Home/Menu screen.
*/
......
......@@ -59,10 +59,6 @@ static const char *FILTERED_BACKGROUND_MUSIC_KEY = "filteredBackgroundMusic";
static const char *BACKGROUND_MUSIC_VOLUME_KEY = "backgroundMusicVolume";
static const char *AUDIO_EFFECTS_VOLUME_KEY = "audioEffectsVolume";
static const char *FILTERED_BACKGROUND_MUSIC_KEY = "filteredBackgroundMusic";
static const char *BACKGROUND_MUSIC_VOLUME_KEY = "backgroundMusicVolume";
static const char *AUDIO_EFFECTS_VOLUME_KEY = "audioEffectsVolume";
static const char *DOWNLOAD_SERVER_URL_KEY = "downloadServerUrl";
static const char *CACHE_PATH_KEY = "cachePath";
static const char *USERDATA_PATH_KEY = "userDataPath";
......
......@@ -213,8 +213,10 @@ Item {
/// @cond INTERNAL_DOCS
function _playNextFile() {
if(files.length == 0)
if(files.length == 0) {
gcaudio.done()
return
}
var nextFile = files.shift()
if(nextFile === '') {
......
......@@ -59,19 +59,19 @@ Window {
/**
* type: bool
* It tells whether the background music is enabled for an activity.
* It tells whether a musical activity is running.
*
* It changes to false if the started activity is a musical activity and back to true when the activity is closed.
* It changes to true if the started activity is a musical activity and back to false when the activity is closed, allowing to play background music.
*/
property bool isBackgroundMusicEnabledInActivity: true
property bool isMusicalActivityRunning: false
/**
* When a musical activity is started, isBackgroundMusicEnabledInActivity changes to false and the backgroundMusic pauses.
* When a musical activity is started, the backgroundMusic pauses.
*
* When returning back from the musical activity to menu, isBackgroundMusicEnabledInActivity changes to true and backgroundMusic resumes.
* When returning back from the musical activity to menu, backgroundMusic resumes.
*/
onIsBackgroundMusicEnabledInActivityChanged: {
if(!isBackgroundMusicEnabledInActivity) {
onIsMusicalActivityRunningChanged: {
if(isMusicalActivityRunning) {
backgroundMusic.pause()
}
else {
......@@ -87,7 +87,7 @@ Window {
}
onClosing: Core.quit(main)
GCAudio {
id: audioVoices
muted: !ApplicationSettings.isAudioVoicesEnabled
......@@ -127,11 +127,8 @@ Window {
GCAudio {
id: backgroundMusic
isBackgroundMusic: true
muted: !ApplicationSettings.isBackgroundMusicEnabled
volume: ApplicationSettings.backgroundMusicVolume
onMutedChanged: {
......@@ -142,24 +139,22 @@ Window {
onDone: backgroundMusic.playBackgroundMusic()
function playBackgroundMusic() {
rccBackgroundMusic = ApplicationInfo.getBackgroundMusicFromRcc()
for(var i = 0; i < filteredBackgroundMusic.length; i++) {
backgroundMusic.append(ApplicationInfo.getAudioFilePath("backgroundMusic/" + filteredBackgroundMusic[i]))
}
if(main.isMusicalActivityRunning)
backgroundMusic.pause()
}
Component.onCompleted: {
if(ApplicationSettings.isBackgroundMusicEnabled)
backgroundMusic.append(ApplicationInfo.getAudioFilePath("qrc:/gcompris/src/core/resource/intro.$CA"))
if(ApplicationSettings.isBackgroundMusicEnabled
&& DownloadManager.haveLocalResource(DownloadManager.getBackgroundMusicResources())) {
backgroundMusic.playBackgroundMusic()
backgroundMusic.playBackgroundMusic()
}
else {
DownloadManager.backgroundMusicRegistered.connect(backgroundMusic.playBackgroundMusic)
......@@ -213,33 +208,34 @@ Window {
if(music == '') {
music = DownloadManager.getBackgroundMusicResources()
}
// We have local music but it is not yet registered
// We have local music but it is not yet registered
else if(!DownloadManager.isDataRegistered("backgroundMusic") && DownloadManager.haveLocalResource(music)) {
// We have music and automatic download is enabled. Download the music and register it
if(DownloadManager.updateResource(music) && DownloadManager.downloadIsRunning()) {
DownloadManager.registerResource(music)
rccBackgroundMusic = Core.shuffle(ApplicationInfo.getBackgroundMusicFromRcc())
}
else {
rccBackgroundMusic = ApplicationInfo.getBackgroundMusicFromRcc()
// We have music and automatic download is enabled. Download the music and register it
if(DownloadManager.updateResource(music) && DownloadManager.downloadIsRunning()) {
DownloadManager.registerResource(music)
rccBackgroundMusic = Core.shuffle(ApplicationInfo.getBackgroundMusicFromRcc())
}
else {
rccBackgroundMusic = ApplicationInfo.getBackgroundMusicFromRcc()
}
}
else if(!DownloadManager.haveLocalResource(music)) {
Core.showMessageDialog(
main,
qsTr("The background music is not yet downloaded. ")
+ qsTr("Do you want to download it now?"),
qsTr("Yes"),
function() {
if(DownloadManager.downloadResource(DownloadManager.getBackgroundMusicResources())) {
var downloadDialog = Core.showDownloadDialog(pageView.currentItem, {});
}
},
qsTr("No"), null,
function() { pageView.currentItem.focus = true }
);
main,
qsTr("The background music is not yet downloaded. ")
+ qsTr("Do you want to download it now?"),
qsTr("Yes"),
function() {
if(DownloadManager.downloadResource(DownloadManager.getBackgroundMusicResources())) {
var downloadDialog = Core.showDownloadDialog(pageView.currentItem, {});
}
},
qsTr("No"), null,
function() { pageView.currentItem.focus = true }
);
}
}
ChangeLog {
id: changelog
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment