zoukankan      html  css  js  c++  java
  • c#播放器

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    
    namespace boxs
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            List<string> a = new List<string>();
            private void button1_Click(object sender, EventArgs e)
            {
                OpenFileDialog od = new OpenFileDialog();
                od.Title = "xx";
                od.InitialDirectory = @"C:Documents and SettingsAdministrator桌面";
                od.Filter = "";
                od.Multiselect = true;
                od.ShowDialog();
                string[] names = od.FileNames;
                foreach (string path in names) 
                {
                    string s_name = Path.GetFileName(path);
                    listBox1.Items.Add(s_name);
                    a.Add(path);
                }
    
            }
    
            private void listBox1_DoubleClick(object sender, EventArgs e)
            {
                string ax = Convert.ToString(a[listBox1.SelectedIndex]);
                axWindowsMediaPlayer1.URL = ax;
                this.button2.Text = "暂停";
                
            }
            private bool b = false;
            private void button2_Click(object sender, EventArgs e)
            {
                if (this.button2.Text == "播放")
                {
                    if (listBox1.Items.Count < 1 || listBox1.SelectedIndex<0)
                    {
                        MessageBox.Show("代码错了");
                        return;
                    }
                        if (b){
                            
                            b = false;
                           
                        }
                        else {
                            string ax = Convert.ToString(a[this.listBox1.SelectedIndex]);
                            axWindowsMediaPlayer1.URL = ax;
                            
                        }
                        axWindowsMediaPlayer1.Ctlcontrols.play();
                        this.button2.Text = "暂停";
                    
                    
                }
                else {
                    axWindowsMediaPlayer1.Ctlcontrols.pause();
                    this.button2.Text = "播放";
                    b = true;
                    
                   
                }
            }
    
            private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
            {
                b = false;
            }
        }
    }
    

      

  • 相关阅读:
    multiview
    RadioButton
    信息存储与管理读书笔记1
    个人Wordpress站点设置Windows Live writer
    test
    test
    AS类库推荐
    JAVA坏境变量中的JAVA_HOME path classpath 的设置与作用
    actionscript3 中关于sprite的mask问题
    RED5遍历客户端并生成在线列表[转]
  • 原文地址:https://www.cnblogs.com/mengluo/p/5484799.html
Copyright © 2011-2022 走看看