private void MaybeUnloadClip() { VarAudio.Stop(); VarAudio.time = 0f; switch (audLocation) { case MasterAudio.AudioLocation.ResourceFile: AudioResourceOptimizer.UnloadClipIfUnused(_resFileName); break; case MasterAudio.AudioLocation.Clip: AudioUtil.UnloadNonPreloadedAudioData(VarAudio.clip, GameObj); break; #if ADDRESSABLES_ENABLED case MasterAudio.AudioLocation.Addressable: VarAudio.clip = null; // must clear out clip so it can be released below. AudioAddressableOptimizer.RemoveAddressablePlayingClip(audioClipAddressable, VarAudio, _isWarmingPlay); break; #endif } LoadStatus = MasterAudio.VariationLoadStatus.None; }
/// <summary> /// This method allows you to stop the audio being played by this Variation. /// </summary> /// <param name="stopEndDetection">Do not ever pass this in.</param> /// <param name="skipLinked">Do not ever pass this in.</param> public void Stop(bool stopEndDetection = false, bool skipLinked = false) { var waitStopped = false; if (stopEndDetection || _isWaitingForDelay) { if (VariationUpdater != null) { VariationUpdater.StopWaitingForFinish(); // turn off the chain loop endless repeat waitStopped = true; } } if (!skipLinked) { PlayEndLinkedGroups(); } _objectToFollow = null; _objectToTriggerFrom = null; ParentGroup.RemoveActiveAudioSourceId(InstanceId); MasterAudio.StopTrackingOcclusionForSource(GameObj); VarAudio.Stop(); VarAudio.time = 0f; if (VariationUpdater != null) { VariationUpdater.StopFollowing(); VariationUpdater.StopFading(); } if (!waitStopped) { if (VariationUpdater != null) { VariationUpdater.StopWaitingForFinish(); } } _playSndParam.IsPlaying = false; if (SoundFinished != null) { var willAbort = _previousSoundFinishedFrame == AudioUtil.FrameCount; _previousSoundFinishedFrame = AudioUtil.FrameCount; if (!willAbort) { SoundFinished(); // parameters aren't used } SoundFinished = null; // clear it out so subscribers don't have to clean up } Trans.localPosition = Vector3.zero; MaybeUnloadClip(); }
/// <summary> /// This method allows you to stop the audio being played by this Variation. /// </summary> public void Stop(bool stopEndDetection = false) { var waitStopped = false; if (stopEndDetection || _isWaitingForDelay) { if (VariationUpdater != null) { VariationUpdater.StopWaitingForFinish(); // turn off the chain loop endless repeat waitStopped = true; } } _objectToFollow = null; _objectToTriggerFrom = null; ParentGroup.RemoveActiveAudioSourceId(InstanceId); VarAudio.Stop(); VarAudio.time = 0f; if (VariationUpdater != null) { VariationUpdater.StopFollowing(); VariationUpdater.StopFading(); } if (!waitStopped) { if (VariationUpdater != null) { VariationUpdater.StopWaitingForFinish(); } } _playSndParam.IsPlaying = false; if (SoundFinished != null) { var willAbort = _previousSoundFinishedFrame == Time.frameCount; _previousSoundFinishedFrame = Time.frameCount; if (!willAbort) { SoundFinished(); // parameters aren't used } SoundFinished = null; // clear it out so subscribers don't have to clean up } MaybeUnloadClip(); }
/// <summary> /// This method allows you to stop the audio being played by this Variation. /// </summary> public void Stop(bool stopEndDetection = false) { if (stopEndDetection || isWaitingForDelay) { curDetectEndMode = DetectEndMode.None; // turn off the chain loop endless repeat } objectToFollow = null; objectToTriggerFrom = null; ParentGroup.RemoveActiveAudioSourceId(InstanceId); VarAudio.Stop(); VarAudio.time = 0f; playSndParams = null; if (SoundFinished != null) { SoundFinished(); // parameters aren't used SoundFinished = null; // clear it out so subscribers don't have to clean up } MaybeUnloadClip(); }
/// <summary> /// This method allows you to stop the audio being played by this Variation. /// </summary> /// <param name="stopEndDetection">Do not ever pass this in.</param> /// <param name="skipLinked">Do not ever pass this in.</param> public void Stop(bool stopEndDetection = false, bool skipLinked = false) { _isPaused = false; var waitStopped = false; if (stopEndDetection) { if (VariationUpdater != null) { VariationUpdater.StopWaitingForFinish(); // turn off the chain loop endless repeat waitStopped = true; } } if (!skipLinked) { PlayEndLinkedGroups(); } _objectToFollow = null; _objectToTriggerFrom = null; VarAudio.pitch = OriginalPitch; ParentGroup.RemoveActiveAudioSourceId(InstanceId); MasterAudio.StopTrackingOcclusionForSource(GameObj); VarAudio.Stop(); VarAudio.time = 0f; if (VariationUpdater != null) { VariationUpdater.StopFollowing(); VariationUpdater.StopFading(); VariationUpdater.StopPitchGliding(); } if (!waitStopped) { if (VariationUpdater != null) { VariationUpdater.StopWaitingForFinish(); } } _playSndParam.IsPlaying = false; if (SoundFinished != null) { var willAbort = _previousSoundFinishedFrame == AudioUtil.FrameCount; _previousSoundFinishedFrame = AudioUtil.FrameCount; if (!willAbort) { SoundFinished(); // parameters aren't used } MaybeCleanupFinishedDelegate(); } Trans.localPosition = Vector3.zero; MaybeUnloadClip(); if (!MasterAudio.IsWarming) // avoids breaking the Variation if warming sound is "Internet file". { DTMonoHelper.SetActive(GameObj, false); } }