c# - Q : WMP 不随机播放基于列表框的选定项目
问题描述
嗨,我正在为简单的媒体播放器工作,我的复选框有问题,它不是洗牌项目......
这是我的以下代码
列表框1
private void listBox1_SelectedIndexChanged_1(object sender, EventArgs e)
{
blumemediaplayer.Ctlcontrols.play();
MediaFile file = listBox1.SelectedItem as MediaFile;
if (file != null)
{
wmp.URL = file.Path;
wmp.Ctlcontrols.play();
}
}
用于改组所选项目的复选框,但它不起作用
bool IsShuffle = false;
MediaFile file = listBox1.SelectedItem as MediaFile;
if (checkBox2.Checked==true)
{
if (wmp.playState == WMPPlayState.wmppsPlaying)
{
// do nothing in this case since song is still playing
}
else
{
if (IsShuffle)
{
Random rand = new Random();
listBox1.SelectedIndex = rand.Next(0, listBox1.Items.Count - 1);
}
else
{
if (listBox1.SelectedIndex + 1 <= listBox1.Items.Count - 1)
{
listBox1.SelectedIndex = listBox1.SelectedIndex + 1;
}
else
{
listBox1.SelectedIndex = 0;
}
}
wmp.URL = file.Path;
}
}
谢谢你 :)
解决方案
推荐阅读
- javascript - 传入的对象无效,应为 ':' 或 '}'
- php - 包含的函数不能在 php 中包含的标头和导航栏文件中工作
- google-cloud-ml - 如何转换为多类分类模型?
- python - Python:PCM 音频操作 - 使用结构时左声道嘈杂
- ibm-mobilefirst - MobileFirst 7.1(错误:“访问服务器已禁用”)
- java - 如何反转二维数组的坐标?
- firebase - Firebase Firestore get() 计为 3 次 api 调用
- reactjs - 使用 asp-prerender-module 时页面不会总是加载,除非解决方案被清理
- excel - 将相同的项目编号合并到一个单元格中类似于连接函数
- python - 将 **kwargs 传递给带有 args 的函数。最佳实践?