MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / playBackground

Method playBackground

Source/Node/AudioSource.cpp:137–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137bool AudioSource::playBackground() {
138 AssertIf(_flags.isOn(Node::Cleanup), "can not operate on an invalid AudioSource");
139 if (_handle != 0 && SharedAudio.isVoicePlaying(_handle)) {
140 return false;
141 }
142 _is3D = false;
143 if (auto audioFile = SharedAudioCache.load(_filename)) {
144 uint32_t busHandle = _bus ? _bus->getHandle() : 0;
145 _pan = 0.0f;
146 auto soloud = SharedAudio.getSoLoud();
147 _handle = soloud->playBackground(*audioFile->getSource(), _volume, false, busHandle);
148 soloud->setProtectVoice(_handle, true);
149 if (_playSpeed != 1.0f) {
150 soloud->setRelativePlaySpeed(_handle, _playSpeed);
151 }
152 if (_loopStartTime > 0.0) {
153 soloud->setLoopPoint(_handle, _loopStartTime);
154 }
155 _protected = true;
156 WRef<AudioSource> self(this);
157 SharedAudio.addRef(_handle, audioFile, [self](uint32_t handle) {
158 if (self && self->_handle == handle) {
159 self->_handle = 0;
160 self->emit("AudioEnd"sv, handle);
161 if (self->_autoRemove) {
162 self->removeFromParent();
163 }
164 }
165 });
166 return true;
167 }
168 return false;
169}
170
171bool AudioSource::play(double delayTime) {
172 AssertIf(_flags.isOn(Node::Cleanup), "can not operate on an invalid AudioSource");

Callers 4

patchAudioSourcePropsFunction · 0.45
playStreamMethod · 0.45

Calls 12

isOnMethod · 0.80
isVoicePlayingMethod · 0.80
getSoLoudMethod · 0.80
setProtectVoiceMethod · 0.80
setRelativePlaySpeedMethod · 0.80
addRefMethod · 0.80
removeFromParentMethod · 0.80
loadMethod · 0.65
getHandleMethod · 0.45
getSourceMethod · 0.45
setLoopPointMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected