Skip to content

[Bug] 循环播放音频报错 #72

Description

@iouter

模块范围

Audio(音频)

严重程度

Broken feature(功能不可用)

发生了什么?

我尝试循环播放bgm,代码是这样的:

var loop = GameAudioService.Shared.PlayLoop(
            AudioSource.Event(path),
            new AudioPlaybackOptions
            {
                Volume = volume,
                Pitch = pitch,
            }
        );

没有效果,并爆出日志(见下面的日志部分)。

复现步骤

执行代码:

var loop = GameAudioService.Shared.PlayLoop(
            AudioSource.Event(path),
            new AudioPlaybackOptions
            {
                Volume = volume,
                Pitch = pitch,
            }
        );

期望行为

我想要循环播放音频

或者循环播放音乐,替换本身的背景音乐也行。其他的api好像都不能实现循环播放?

日志 / 堆栈

ERROR: Cannot set parameter loop to value 0.000000void __cdecl godot::FmodEvent::set_parameter_by_name(const class godot::String &,float) constsrc\studio\fmod_event.cpp69
   at: push_error (core/variant/variant_utility.cpp:1024)
   C# backtrace (most recent call first):
       [0] Godot.Variant Godot.NativeCalls.godot_icall_2_875(nint, nint, Godot.NativeInterop.godot_string_name, System.ReadOnlySpan`1[Godot.Variant], Godot.NativeInterop.godot_string_name)
       [1] Godot.Variant Godot.GodotObject.Call(Godot.StringName, Godot.Variant[])
       [2] bool STS2RitsuLib.Audio.AudioHandleBase.TryCall(string, Godot.Variant[]) (F:\Github\sts-2-opencode\sts-2-ritsulib\src\Audio\AudioHandleBase.cs:225)
       [3] bool STS2RitsuLib.Audio.AudioHandleBase.TrySetParameter(string, float) (F:\Github\sts-2-opencode\sts-2-ritsulib\src\Audio\AudioHandleBase.cs:154)
       [4] STS2RitsuLib.Audio.AudioPlayResult STS2RitsuLib.Audio.GameAudioService.AttachStudioLoop(STS2RitsuLib.Audio.AudioSource, Godot.GodotObject, STS2RitsuLib.Audio.AudioPlaybackOptions) (F:\Github\sts-2-opencode\sts-2-ritsulib\src\Audio\GameAudioService.cs:182)
       [5] STS2RitsuLib.Audio.AudioPlayResult STS2RitsuLib.Audio.GameAudioService.PlayStudioLoop(STS2RitsuLib.Audio.StudioEventSource, STS2RitsuLib.Audio.AudioPlaybackOptions) (F:\Github\sts-2-opencode\sts-2-ritsulib\src\Audio\GameAudioService.cs:155)
       [6] STS2RitsuLib.Audio.AudioLoopHandle STS2RitsuLib.Audio.GameAudioService.PlayLoop(STS2RitsuLib.Audio.AudioSource, STS2RitsuLib.Audio.AudioPlaybackOptions) (F:\Github\sts-2-opencode\sts-2-ritsulib\src\Audio\GameAudioService.cs:73)
       [7] void LexNinja2.LexNinja2Code.Api.NinjaAudio.PlayLooped(string, float, float) (.\LexNinja2Code\Api\NinjaAudio.cs:31)
       [8] void LexNinja2.LexNinja2Code.Cards.Events.AlanWalker+<OnPlay>d__5.MoveNext() (.\LexNinja2Code\Cards\Events\AlanWalker.cs:31)
       [9] void System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, object)
       [10] void System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1.MoveNext(System.Threading.Thread)
       [11] void System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.ContextCallback, object, System.Threading.Tasks.Task&)
       [12] void System.Threading.Tasks.Task.RunContinuations(object)
       [13] bool System.Threading.Tasks.Task`1.TrySetResult(TResult)
       [14] void System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.SetExistingTaskResult(System.Threading.Tasks.Task`1[TResult], TResult)
       [15] void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult()
       [16] void MegaCrit.Sts2.Core.Commands.Cmd+<Wait>d__1.MoveNext()
       [17] void System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1.ExecutionContextCallback(object)
       [18] void System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, object)
       [19] void System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1.MoveNext(System.Threading.Thread)
       [20] void System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1.MoveNext()
       [21] void System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.ContextCallback, object, System.Threading.Tasks.Task&)
       [22] void System.Threading.Tasks.Task.RunContinuations(object)
       [23] bool System.Threading.Tasks.Task.TrySetResult()
       [24] bool System.Threading.Tasks.TaskCompletionSource.TrySetResult()
       [25] void MegaCrit.Sts2.Core.Commands.Cmd+<>c__DisplayClass2_0.<WaitInternal>g__Receive|0()
       [26] void Godot.Callable.<From>g__Trampoline|1_0(object, Godot.NativeInterop.NativeVariantPtrArgs, Godot.NativeInterop.godot_variant&)
       [27] void Godot.DelegateUtils.InvokeWithVariantArgs(nint, System.Void*, Godot.NativeInterop.godot_variant**, int, Godot.NativeInterop.godot_variant*)

RitsuLib 版本

0.4.41

运行环境

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/audioFMOD, banks, sound events, or audio playback.priority/p1High priority regression or high-impact work.severity/brokenA feature path is effectively unusable.status/needs-triageNeeds maintainer or analyzer triage.type/docsDocumentation, examples, or README work.type/questionUsage, design, or contribution question.wontfixAccepted as not planned for this project.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions