【发布时间】:2014-06-22 01:16:30
【问题描述】:
我正在尝试制作一个像幻灯片一样显示图像的程序,每次显示图片时,都会为当前图像播放声音,每张图像都会播放不同的声音。 如何使用带有声音的数组并播放数组中的声音?
string[] sounds = new string[] { "nero", "fai", "mpanio", "tv1", "volta",
"sleep1" };
private int currentAudioIndex = 0;
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Stop();
try
{
timer1.Interval = 5000; // Next time, wait 5 secs
button1.BackgroundImage = (Image)Properties.Resources.ResourceManager.GetObject(arr1[currentImageIndex]);
new SoundPlayer(Properties.Resources.nero).Play();// plays only one sound "nero"
currentImageIndex++;
}
finally
{
if (currentImageIndex < arr1.Length)
timer1.Start();
}
}
【问题讨论】:
-
通常情况下,您会拥有声音文件列表 - 存储在硬盘驱动器上或在线,并且您将存储这些文件的 url(或路径)列表以播放它们。也就是说,使用众多免费的视频和幻灯片创建程序之一来制作幻灯片并将其保存为真正的视频文件似乎要容易得多。
-
音频文件位于程序的资源文件夹中。我不想要视频,我会在程序中添加更多内容,目前我遇到了这个问题,只是在每次图片更改时播放数组中的声音
标签: c# arrays audio slideshow soundplayer