自己做的一个千千静听
来源:互联网 发布:淘宝拒收 编辑:程序博客网 时间:2024/06/02 09:07
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- namespace wanwanjingting
- {
- public partial class Form1 : Form
- {
- private String [] filenames=new string[100];
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- timer1.Start();
- timer1.Interval = 1000;
- timer1.Tick += new EventHandler(timer1_Tick);
- }
- private void button1_Click(object sender, EventArgs e)
- {
- OpenFileDialog fdlg = new OpenFileDialog();
- fdlg.InitialDirectory = "d://";
- fdlg.Multiselect = true;
- if (fdlg.ShowDialog() == DialogResult.OK)
- {
- filenames=fdlg.FileNames;
- foreach (String a in filenames)
- {
- listBox1.Items.Add(a);
- }
- axWindowsMediaPlayer1.URL = filenames[listBox1.SelectedIndex+1];
- }
-
- }
- private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (listBox1.SelectedItem!=null)
- axWindowsMediaPlayer1.URL = filenames[listBox1.SelectedIndex];
-
- }
- private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
- {
-
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (axWindowsMediaPlayer1.playState == (WMPLib.WMPPlayState)1)
- {
- if (listBox1.SelectedIndex ==listBox1.Items.Count-1)
- {
- listBox1.SelectedIndex = 0;
- }
- else
- {
- listBox1.SelectedIndex++;
- axWindowsMediaPlayer1.URL = filenames[listBox1.SelectedIndex + 1];
- }
- }
-
- }
- private void button2_Click(object sender, EventArgs e)
- {
- listBox1.Items.Remove(listBox1.SelectedItem);
- }
- }
- }