Warning, /education/gcompris/src/core/GCSfx.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - GCSfx.qml 0002 * 0003 * SPDX-FileCopyrightText: 2018 Timothée Giet <animtim@gmail.com> 0004 * 0005 * Authors: 0006 * Johnny Jazeix <jazeix@gmail.com> (GCAudio base, 2014) 0007 * Timothée Giet <animtim@gmail.com> 0008 * 0009 * SPDX-License-Identifier: GPL-3.0-or-later 0010 */ 0011 import QtQuick 2.12 0012 import QtMultimedia 5.12 0013 import GCompris 1.0 0014 0015 /** 0016 * A QML component for sfx playback. 0017 * @ingroup components 0018 * 0019 * Wrapper component around QtQuick's SoundEffect element, handling all sfx 0020 * playback in GCompris uniformly. 0021 * 0022 * 0023 * @inherit QtQuick.Item 0024 */ 0025 Item { 0026 id: gcsfx 0027 0028 /** 0029 * type:bool 0030 * Whether sfx should be muted. 0031 */ 0032 property alias muted: sfx.muted 0033 0034 /** 0035 * type:real 0036 * Volume of the fx player. 0037 */ 0038 property alias volume: sfx.volume 0039 0040 /** 0041 * type:url 0042 * URL to the sfx source to be played back. 0043 */ 0044 property alias source: sfx.source 0045 0046 /** 0047 * type:string 0048 * Status of the fx player. 0049 */ 0050 property alias status: sfx.status 0051 0052 /** 0053 * type:bool 0054 * Status of the fx player. 0055 */ 0056 property alias playing: sfx.playing 0057 0058 /** 0059 * Emitted when playback of sound has finished. 0060 */ 0061 signal done 0062 0063 /** 0064 * Plays back the sfx resource @p file. 0065 * 0066 * @param type:string file [optional] URL to an sfx source. 0067 * @returns @c true if playback has been started, @c false if file does not 0068 * exist or sfx is muted 0069 */ 0070 function play(file) { 0071 if(file) { 0072 source = file 0073 } 0074 if(!muted) { 0075 sfx.play() 0076 } 0077 } 0078 0079 /** 0080 * Stops sfx playback. 0081 */ 0082 function stop() { 0083 if(sfx.playing) 0084 sfx.stop() 0085 } 0086 0087 /// @cond INTERNAL_DOCS 0088 0089 SoundEffect { 0090 id: sfx 0091 onPlayingChanged: { 0092 if(!playing){ 0093 gcsfx.done(); 0094 } 0095 } 0096 } 0097 0098 /// @endcond 0099 0100 }