收藏 分享(赏)

C#播放器.doc

上传人:gnk289057 文档编号:9468163 上传时间:2019-08-09 格式:DOC 页数:14 大小:166KB
下载 相关 举报
C#播放器.doc_第1页
第1页 / 共14页
C#播放器.doc_第2页
第2页 / 共14页
C#播放器.doc_第3页
第3页 / 共14页
C#播放器.doc_第4页
第4页 / 共14页
C#播放器.doc_第5页
第5页 / 共14页
点击查看更多>>
资源描述

1、以下是全部代码:1.Form1.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Collections;namespace 自制影音播放器public partial class Form1 : Formpublic Form1()InitializeComponent();ArrayList str

2、Filenames = new ArrayList(); /存放完整文件名private void button1_Click(object sender, EventArgs e)OpenFileDialog openFile = new OpenFileDialog();openFile.Multiselect = true;DialogResult dr = openFile.ShowDialog();if (dr = DialogResult.OK)int count = lstFilm.Items.Count;/记录添加前的项数/取得文件主名并在列表框中显示 foreach (str

3、ing name in openFile.FileNames)strFilenames.Add(name);lstFilm.Items.Add(System.IO.Path.GetFileNameWithoutExtension(name);/默认播放刚添加的第一个 lstFilm.SelectedIndex = count;private void listBox1_SelectedIndexChanged(object sender, EventArgs e)Player.URL = strFilenameslstFilm.SelectedIndex.ToString();lblTime.

4、Text = “00:00n“ + Player.currentMedia.durationString;timer1.Enabled = true;private void button2_Click(object sender, EventArgs e)Player.Ctlcontrols.play();private void button3_Click(object sender, EventArgs e)Player.Ctlcontrols.pause();private void button4_Click(object sender, EventArgs e)if (lstFil

5、m.SelectedIndex 0)lstFilm.SelectedIndex -= 1;elselstFilm.SelectedIndex = lstFilm.Items.Count - 1;private void button5_Click(object sender, EventArgs e)if (lstFilm.SelectedIndex 1000)trackProcess.TickFrequency = trackProcess.Maximum / 100;elsetrackProcess.TickFrequency = trackProcess.Maximum / 20;/音量

6、trackVolume.Maximum = 100;trackVolume.Minimum = 0;trackVolume.TickFrequency = 10;trackVolume.Value = Player.settings.volume;lblTime.Text = “00:00n“ + Player.currentMedia.durationString;private void trackProcess_Scroll(object sender, EventArgs e)Player.Ctlcontrols.currentPosition = trackProcess.Value

7、;private void trackVolume_Scroll(object sender, EventArgs e)Player.settings.volume = trackVolume.Value;private void 退出XToolStripMenuItem_Click( object sender, EventArgs e)Application.Exit();private void toolStripMenuItem1_Click(object sender, EventArgs e)strFilenames.Clear();lstFilm.Items.Clear();2.

8、Program.csusing System;using System.Collections.Generic;using System.Windows.Forms;namespace 自制影音播放器static class Program/ / 应用程序的主入口点。/ STAThreadstatic void Main()Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(new Form1();3.Form1.Designer.csname

9、space 自制影音播放器partial class Form1/ / 必需的设计器变量。/ private System.ComponentModel.IContainer components = null;/ / 清理所有正在使用的资源。/ / 如果应释放托管资源,为 true;否则为 false。protected override void Dispose(bool disposing)if (disposing base.Dispose(disposing);#region Windows 窗体设计器生成的代码/ / 设计器支持所需的方法 - 不要/ 使用代码编辑器修改此方法的内容

10、。/ private void InitializeComponent()ponents = new System.ComponentModel.Container();System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1);this.panel1 = new System.Windows.Forms.Panel();this.splitter1 = new System.Windows.Forms.Sp

11、litter();this.lstFilm = new System.Windows.Forms.ListBox();this.panel2 = new System.Windows.Forms.Panel();this.panel4 = new System.Windows.Forms.Panel();this.trackProcess = new System.Windows.Forms.TrackBar();this.lblTime = new System.Windows.Forms.Label();this.panel3 = new System.Windows.Forms.Pane

12、l();this.panel5 = new System.Windows.Forms.Panel();this.trackVolume = new System.Windows.Forms.TrackBar();this.button6 = new System.Windows.Forms.Button();this.button5 = new System.Windows.Forms.Button();this.button4 = new System.Windows.Forms.Button();this.button3 = new System.Windows.Forms.Button(

13、);this.button2 = new System.Windows.Forms.Button();this.button1 = new System.Windows.Forms.Button();this.menuStrip1 = new System.Windows.Forms.MenuStrip();this.文件FToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();this.打开OToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem()

14、;this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();this.退出XToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();this.timer1 = new System.Windows.Forms.Timer(ponents);this.toolTip1 = new System.W

15、indows.Forms.ToolTip(ponents);this.Player = new AxWMPLib.AxWindowsMediaPlayer();this.panel1.SuspendLayout();this.panel2.SuspendLayout();this.panel4.SuspendLayout();(System.ComponentModel.ISupportInitialize)(this.trackProcess).BeginInit();this.panel3.SuspendLayout();this.panel5.SuspendLayout();(Syste

16、m.ComponentModel.ISupportInitialize)(this.trackVolume).BeginInit();this.menuStrip1.SuspendLayout();(System.ComponentModel.ISupportInitialize)(this.Player).BeginInit();this.SuspendLayout();/ / panel1/ this.panel1.Controls.Add(this.Player);this.panel1.Controls.Add(this.splitter1);this.panel1.Controls.

17、Add(this.lstFilm);this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;this.panel1.Location = new System.Drawing.Point(0, 24);this.panel1.Name = “panel1“;this.panel1.Size = new System.Drawing.Size(534, 289);this.panel1.TabIndex = 2;/ / splitter1/ this.splitter1.Location = new System.Drawing.Point(

18、131, 0);this.splitter1.Name = “splitter1“;this.splitter1.Size = new System.Drawing.Size(3, 289);this.splitter1.TabIndex = 5;this.splitter1.TabStop = false;/ / lstFilm/ this.lstFilm.Dock = System.Windows.Forms.DockStyle.Left;this.lstFilm.FormattingEnabled = true;this.lstFilm.IntegralHeight = false;th

19、is.lstFilm.ItemHeight = 12;this.lstFilm.Location = new System.Drawing.Point(0, 0);this.lstFilm.Name = “lstFilm“;this.lstFilm.Size = new System.Drawing.Size(131, 289);this.lstFilm.TabIndex = 4;this.toolTip1.SetToolTip(this.lstFilm, “播放文件列表“);this.lstFilm.SelectedIndexChanged += new System.EventHandle

20、r(this.listBox1_SelectedIndexChanged);/ / panel2/ this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;this.panel2.Controls.Add(this.panel4);this.panel2.Controls.Add(this.panel3);this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;this.panel2.Location = new System.Drawing.P

21、oint(0, 313);this.panel2.Name = “panel2“;this.panel2.Size = new System.Drawing.Size(534, 38);this.panel2.TabIndex = 3;/ / panel4/ this.panel4.Controls.Add(this.trackProcess);this.panel4.Controls.Add(this.lblTime);this.panel4.Dock = System.Windows.Forms.DockStyle.Fill;this.panel4.Location = new Syste

22、m.Drawing.Point(297, 0);this.panel4.Name = “panel4“;this.panel4.Size = new System.Drawing.Size(237, 38);this.panel4.TabIndex = 1;/ / trackProcess/ this.trackProcess.AutoSize = false;this.trackProcess.Dock = System.Windows.Forms.DockStyle.Fill;this.trackProcess.Location = new System.Drawing.Point(71,

23、 0);this.trackProcess.Name = “trackProcess“;this.trackProcess.Size = new System.Drawing.Size(166, 38);this.trackProcess.TabIndex = 0;this.toolTip1.SetToolTip(this.trackProcess, “播放进度,可以通过拖动滑块进行调节“ );this.trackProcess.Scroll += new System.EventHandler(this.trackProcess_Scroll);/ / lblTime/ this.lblTi

24、me.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.lblTime.Dock = System.Windows.Forms.DockStyle.Left;this.lblTime.Font = new System.Drawing.Font(“宋体“, 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (byte)(134);this.lblTime.Location = new System.Drawing.P

25、oint(0, 0);this.lblTime.Name = “lblTime“;this.lblTime.Size = new System.Drawing.Size(71, 38);this.lblTime.TabIndex = 1;this.lblTime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;this.toolTip1.SetToolTip(this.lblTime, “已播放时间/总时间“);/ / panel3/ this.panel3.Controls.Add(this.panel5);this.pane

26、l3.Controls.Add(this.button6);this.panel3.Controls.Add(this.button5);this.panel3.Controls.Add(this.button4);this.panel3.Controls.Add(this.button3);this.panel3.Controls.Add(this.button2);this.panel3.Controls.Add(this.button1);this.panel3.Dock = System.Windows.Forms.DockStyle.Left;this.panel3.Location

27、 = new System.Drawing.Point(0, 0);this.panel3.Name = “panel3“;this.panel3.Size = new System.Drawing.Size(297, 38);this.panel3.TabIndex = 0;/ / panel5/ this.panel5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.panel5.Controls.Add(this.trackVolume);this.panel5.Location = new System.D

28、rawing.Point(196, 3);this.panel5.Name = “panel5“;this.panel5.Size = new System.Drawing.Size(98, 32);this.panel5.TabIndex = 6;/ / trackVolume/ this.trackVolume.AutoSize = false;this.trackVolume.Location = new System.Drawing.Point(2, 2);this.trackVolume.Name = “trackVolume“;this.trackVolume.Size = new

29、 System.Drawing.Size(91, 29);this.trackVolume.TabIndex = 0;this.toolTip1.SetToolTip(this.trackVolume, “音量调节“);this.trackVolume.Scroll += new System.EventHandler(this.trackVolume_Scroll);/ / button6/ this.button6.BackgroundImage = (System.Drawing.Image)(resources.GetObject(“button6.BackgroundImage“);

30、this.button6.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;this.button6.Location = new System.Drawing.Point(163, 3);this.button6.Name = “button6“;this.button6.Size = new System.Drawing.Size(32, 32);this.button6.TabIndex = 5;this.toolTip1.SetToolTip(this.button6, “停止“ );this.button

31、6.UseVisualStyleBackColor = true;this.button6.Click += new System.EventHandler(this.button6_Click);/ / button5/ this.button5.BackgroundImage = (System.Drawing.Image)(resources.GetObject(“button5.BackgroundImage“);this.button5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;this.butt

32、on5.Location = new System.Drawing.Point(131, 3);this.button5.Name = “button5“;this.button5.Size = new System.Drawing.Size(32, 32);this.button5.TabIndex = 4;this.toolTip1.SetToolTip(this.button5, “下一首( 部)“ );this.button5.UseVisualStyleBackColor = true;this.button5.Click += new System.EventHandler(thi

33、s.button5_Click);/ / button4/ this.button4.BackgroundImage = (System.Drawing.Image)(resources.GetObject(“button4.BackgroundImage“);this.button4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;this.button4.Location = new System.Drawing.Point(99, 3);this.button4.Name = “button4“;this.

34、button4.Size = new System.Drawing.Size(32, 32);this.button4.TabIndex = 3;this.toolTip1.SetToolTip(this.button4, “上一首( 部)“ );this.button4.UseVisualStyleBackColor = true;this.button4.Click += new System.EventHandler(this.button4_Click);/ / button3/ this.button3.BackgroundImage = (System.Drawing.Image)

35、(resources.GetObject(“button3.BackgroundImage“);this.button3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;this.button3.Location = new System.Drawing.Point(67, 3);this.button3.Name = “button3“;this.button3.Size = new System.Drawing.Size(32, 32);this.button3.TabIndex = 2;this.toolT

36、ip1.SetToolTip(this.button3, “暂停“ );this.button3.UseVisualStyleBackColor = true;this.button3.Click += new System.EventHandler(this.button3_Click);/ / button2/ this.button2.BackgroundImage = (System.Drawing.Image)(resources.GetObject(“button2.BackgroundImage“);this.button2.BackgroundImageLayout = Sys

37、tem.Windows.Forms.ImageLayout.Stretch;this.button2.Location = new System.Drawing.Point(35, 3);this.button2.Name = “button2“;this.button2.Size = new System.Drawing.Size(32, 32);this.button2.TabIndex = 1;this.toolTip1.SetToolTip(this.button2, “播放“ );this.button2.UseVisualStyleBackColor = true;this.but

38、ton2.Click += new System.EventHandler(this.button2_Click);/ / button1/ this.button1.BackgroundImage = (System.Drawing.Image)(resources.GetObject(“button1.BackgroundImage“);this.button1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;this.button1.Location = new System.Drawing.Point(3,

39、 3);this.button1.Name = “button1“;this.button1.Size = new System.Drawing.Size(32, 32);this.button1.TabIndex = 0;this.toolTip1.SetToolTip(this.button1, “选择影音文件“ );this.button1.UseVisualStyleBackColor = true;this.button1.Click += new System.EventHandler(this.button1_Click);/ / menuStrip1/ this.menuStr

40、ip1.Items.AddRange(new System.Windows.Forms.ToolStripItem this.文件FToolStripMenuItem);this.menuStrip1.Location = new System.Drawing.Point(0, 0);this.menuStrip1.Name = “menuStrip1“;this.menuStrip1.Size = new System.Drawing.Size(534, 24);this.menuStrip1.TabIndex = 4;this.menuStrip1.Text = “menuStrip1“;

41、/ / 文件FToolStripMenuItem/ this.文件FToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem this.打开OToolStripMenuItem,this.toolStripMenuItem1,this.toolStripSeparator1,this.退出XToolStripMenuItem);this.文件FToolStripMenuItem.Name = “文件FToolStripMenuItem“;this.文件FToolStripMenuItem.Si

42、ze = new System.Drawing.Size(59, 20);this.文件FToolStripMenuItem.Text = “文件(/ / 打开OToolStripMenuItem/ this.打开OToolStripMenuItem.Name = “打开OToolStripMenuItem“;this.打开OToolStripMenuItem.Size = new System.Drawing.Size(160, 22);this.打开OToolStripMenuItem.Text = “打开(this.打开OToolStripMenuItem.Click += new Sy

43、stem.EventHandler(this.button1_Click);/ / toolStripMenuItem1/ this.toolStripMenuItem1.Name = “toolStripMenuItem1“;this.toolStripMenuItem1.Size = new System.Drawing.Size(160, 22);this.toolStripMenuItem1.Text = “清空播放列表(this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Cl

44、ick);/ / toolStripSeparator1/ this.toolStripSeparator1.Name = “toolStripSeparator1“;this.toolStripSeparator1.Size = new System.Drawing.Size(157, 6);/ / 退出XToolStripMenuItem/ this.退出XToolStripMenuItem.Name = “退出XToolStripMenuItem“;this.退出XToolStripMenuItem.Size = new System.Drawing.Size(160, 22);this

45、.退出XToolStripMenuItem.Text = “退出(this.退出XToolStripMenuItem.Click += new System.EventHandler(this.退出XToolStripMenuItem_Click);/ / timer1/ this.timer1.Interval = 1000;this.timer1.Tick += new System.EventHandler(this.timer1_Tick);/ / Player/ this.Player.Dock = System.Windows.Forms.DockStyle.Fill;this.P

46、layer.Enabled = true;this.Player.Location = new System.Drawing.Point(134, 0);this.Player.Name = “Player“;this.Player.OcxState = (System.Windows.Forms.AxHost.State)(resources.GetObject(“Player.OcxState“);this.Player.Size = new System.Drawing.Size(400, 289);this.Player.TabIndex = 1;this.Player.MediaCh

47、ange += new AxWMPLib._WMPOCXEvents_MediaChangeEventHandler(this.Player_MediaChange);/ / Form1/ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;this.ClientSize = new System.Drawing.Size(534, 351);this.Controls.Add(this.panel1);

48、this.Controls.Add(this.menuStrip1);this.Controls.Add(this.panel2);this.Name = “Form1“;this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;this.Text = “自制影音播放器“;this.TopMost = true;this.Load += new System.EventHandler(this.Form1_Load);this.panel1.ResumeLayout(false);this.panel2.R

49、esumeLayout(false);this.panel4.ResumeLayout(false);(System.ComponentModel.ISupportInitialize)(this.trackProcess).EndInit();this.panel3.ResumeLayout(false);this.panel5.ResumeLayout(false);(System.ComponentModel.ISupportInitialize)(this.trackVolume).EndInit();this.menuStrip1.ResumeLayout(false);this.menuStrip1.PerformLayout();(System.ComponentModel.ISu

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报