【问题标题】:Play Sound in MonoTouch for specific duration在 MonoTouch 中播放特定持续时间的声音
【发布时间】:2013-09-03 20:13:37
【问题描述】:

使用 MonoTouch 库,我想做的是能够播放一段特定持续时间的声音,然后停止播放。它必须在与 UI 不同的线程上完成。我已经修改了几个不同的选项,但我不完全确定目前最好的行动方案是什么。

这些类看起来像这样:

public class Foo
{
    public string FileName { get; set; }
    public string FilePath { get; set; }
    public double Duration { get; set; }
    public double PauseAfter { get; set; }
}

public class FooPlayer
{
    public List<Foo> Foos { get; set; }

    public void PlayFoos()
    {
        foreach (Foo f in Foos)
        {
             //Play the sound
             //Stop the sound after the duration has passed
             //Wait for the duration specified in PauseAfter
             //Continue loop
        }
    }
}   

我一直在修改 SystemSound 和 AvAudioPlayer,但还没有得到所需的结果。

【问题讨论】:

    标签: c# xamarin.ios


    【解决方案1】:

    使用计时器,计时器触发后停止播放。一个类似的问题是here,有一个类似的答案(使用计时器)但在 Obj-C 中。

    【讨论】:

    • Obj-C 对我没有多大帮助,因为 1) Play() 是同步的,不只是在计时器启动或消逝之前完成? 2) 我不知道这是否有任何东西会阻塞 UI 线程
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-14
    • 1970-01-01
    • 1970-01-01
    • 2012-09-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多