0

Using the MonoTouch libraries, what I would like to do is being able to play a sound for a specific duration and then stop playback. It must be done on a different thread than the UI. I've tinkered with a few different options, and I'm not entirely sure what the best course of action is at this point.

The classes look something like this:

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
        }
    }
}   

I've been tinkering with SystemSound and AvAudioPlayer but I'm yet to get the required result.

4

1 回答 1

0

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

于 2013-09-03T20:43:30.460 回答