Winform Windows Media Player 简易播放器

新手上路,高手勿进!

窗体设计:

实现效果:

实现代码:

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.Data.SqlClient;

using System.Runtime.InteropServices;

using System.IO;

using System.Collections;

using System.Media;

namespace Music {

public partial class LenMusic : Form {

public LenMusic() {

InitializeComponent();

}

#region

string strMusic = "";//音乐路径

string strImage = "";//图片路径

string strGeci = "";//歌词路径

ArrayList musicNameList = new ArrayList();//所有文件的名称

ArrayList imageNameList = new ArrayList();//所有图片的名称

ArrayList geciNameList = new ArrayList();//所有歌词路径

int allcount = 0;//所有条数

int nowcount = 0;//当前歌曲的索引

string abcMusic = "";//记录当前播放的歌曲名称,用于单曲循环播放

bool MaxOrNo = false;//判断一个窗体是否是最大化

int txtn = 0;//txt文件的行数

#endregion

[DllImport("kernel32")]

private static extern long WritePrivateProfileString(string section, string key, string val, string filepath);

[DllImport("kernel32")]

private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retval, int size, string filePath);

private string strFilePath = Application.StartupPath + "\\Path.ini";//获取INI文件路径

private string strSec = "";//INI文件名

/// <summary>

/// 自定义读取INI文件中的内容方法

/// </summary>

/// <param name="Section">键</param>

/// <param name="key">值</param>

/// <returns></returns>

private string ContentValue(string Section, string key) {

StringBuilder temp = new StringBuilder(1024);

GetPrivateProfileString(Section, key, "", temp, 1024, strFilePath);

return temp.ToString();

}

#region Load事件

private void LenMusic_Load(object sender, EventArgs e) {

//设置层显示

grbSet.Visible = false;

pnlMusic.Visible = true;

//歌词路径赋值

strGeci = Application.StartupPath + "\\txtGeCi";

#region 获取歌曲名称,图片名称,歌词名称

if (File.Exists(strFilePath))//读取时先要判读INI文件是否存在

{

strSec = Path.GetFileNameWithoutExtension(strFilePath);

strMusic = ContentValue(strSec, "musicPath");

strImage = ContentValue(strSec, "imagePath");

//设置路径的默认值

string XiangDuiPath = System.AppDomain.CurrentDomain.BaseDirectory;

if (strMusic.Equals("")) {

strMusic = XiangDuiPath + @"MP3";

}

if (strImage.Equals("")) {

strImage = XiangDuiPath + @"images";

}

} else {

MessageBox.Show("INI文件不存在");

return;

}

// 取得指定路径下所有符合条件的文件

string[] strFiles = Directory.GetFiles(strMusic, "*.*");

// 取得指定路径下所有目录

//string[] strDirs = Directory.GetDirectories(strMusic);

//foreach (string lujing in strDirs) {

//    musicList.Add(lujing);

//}

foreach (string name in strFiles) {

musicNameList.Add(GetFileName(name));

}

//获取指定目录下所有图片的名称

string[] strFilesImage = Directory.GetFiles(strImage, "*.*");

foreach (string name in strFilesImage) {

imageNameList.Add(GetFileName(name));

}

//获取指定目录下所有歌词的名称

string[] strFilesGeci = Directory.GetFiles(strGeci, "*.*");

foreach (string name in strFilesGeci) {

geciNameList.Add(GetFileName(name));

}

#endregion

#region ListView设置

listViewAll.GridLines = true;

listViewAll.FullRowSelect = true;

listViewAll.View = View.Details;//使用哪一个视图

listViewAll.Scrollable = false;

listViewAll.MultiSelect = false;

listViewAll.HeaderStyle = ColumnHeaderStyle.Clickable;

listViewAll.Columns.Add("序号", 40, HorizontalAlignment.Right);

listViewAll.Columns.Add("歌曲", 173, HorizontalAlignment.Left);

//设置行高

ImageList list = new ImageList();

list.ImageSize = new Size(1, 30);

listViewAll.SmallImageList = list;

//加载ListView数据

for (int i = 0; i < musicNameList.Count; i++) {

ListViewItem lvi = new ListViewItem();

lvi.SubItems.Clear();

lvi.Text = (i + 1).ToString();//序号列

lvi.SubItems.Add(musicNameList[i].ToString());//歌曲名称

listViewAll.Items.Add(lvi);

}

#endregion

#region 歌曲默认为第一首

try {

//歌曲默认为第一首

labName.Text = musicNameList[0].ToString();

} catch {

labName.Text = "歌曲名称";

}

#endregion

//歌曲总数

allcount = musicNameList.Count;

//设置模式

this.axWindowsMediaPlayer1.uiMode = "None";

#region 声音加载

this.tbVoice.Minimum = 0;//声音最小值

this.tbVoice.Maximum = 100;//声音最大值

//设置值

this.tbVoice.Value = axWindowsMediaPlayer1.settings.volume;

#endregion

#region 透明 设置

#region 设置pnlFontScoll

this.pnlMusic.SendToBack();//将背景图片放到最下面

this.pnlFontScoll.BackColor = Color.Transparent;//将Panel设为透明

this.pnlFontScoll.Parent = this.pnlMusic;//将panel父控件设为背景图片控件

this.pnlFontScoll.BringToFront();//将panel放在前面

#endregion

#region 歌词透明,歌词字体设置

//透明Label

this.pbPicture.SendToBack();

this.labGeci.BackColor = Color.Transparent;

this.labGeci.Parent = this.pbPicture;

this.labGeci.BringToFront();

//设置字体和颜色

this.labGeci.ForeColor = Color.Yellow;

this.labGeci.Font = new Font("华文行楷", 14);

#endregion

#region 透明层 设置picturebox

this.pbPicture.SendToBack();//将背景图片放到最下面

this.pnlTouMing.BackColor = Color.Transparent;//将Panel设为透明

this.pnlTouMing.Parent = this.pbPicture;//将panel父控件设为背景图片控件

this.pnlTouMing.BringToFront();//将panel放在前面

#endregion

//listViewAll 不支持背景色透明

#endregion

}

#endregion

#region 获取文件名称

public static string GetFileName(String path) {

if (path.Contains("\\")) {

string[] arr = path.Split(‘\\‘);

return arr[arr.Length - 1];

} else {

string[] arr = path.Split(‘/‘);

return arr[arr.Length - 1];

}

}

#endregion

#region 系统设置

private void pbSet_Click(object sender, EventArgs e) {

pnlMusic.Visible = false;

grbSet.Visible = true;

//从INI文件中读取数据

if (File.Exists(strFilePath))//读取时先要判读INI文件是否存在

{

strSec = Path.GetFileNameWithoutExtension(strFilePath);

txtMusicPath.Text = ContentValue(strSec, "musicPath");

txtImagePath.Text = ContentValue(strSec, "imagePath");

} else {

MessageBox.Show("INI文件不存在");

return;

}

}

//打开音乐路径

private void btnMusicPath_Click(object sender, EventArgs e) {

OpenFileDialog open = new OpenFileDialog();

open.Title = "请选择音乐文件!";

if (open.ShowDialog() == DialogResult.OK) {

txtMusicPath2.Text = open.FileName;

}

}

private void btnMusicPath_Click_1(object sender, EventArgs e) {

fbdMusic.Description = "请选择音乐文件!";

if (fbdMusic.ShowDialog() == DialogResult.OK) {

txtMusicPath.Text = fbdMusic.SelectedPath;

}

}

//打开音乐图片路径

private void btnImagePath_Click(object sender, EventArgs e) {

//fbdImages.t

fbdImages.Description = "选择的图片将在播放音乐时作为背景图片!";

if (fbdImages.ShowDialog() == DialogResult.OK) {

txtImagePath.Text = fbdImages.SelectedPath;

}

}

//保存,成功则自动关闭

private void btnSave_Click(object sender, EventArgs e) {

if (txtMusicPath.Text.Trim().Equals("")) {

MessageBox.Show("音乐路径不能为空!");

return;

}

if (txtImagePath.Text.Trim().Equals("")) {

MessageBox.Show("图片路径不能为空!");

return;

}

//StreamWriter sw = new StreamWriter(System.AppDomain.CurrentDomain + "\\Path.ini",true);

//sw.WriteLine(txtMusicPath.Text);

//sw.WriteLine(txtImagePath.Text);

//sw.Flush();

//sw.Close();

try {

strSec = Path.GetFileNameWithoutExtension(strFilePath);

WritePrivateProfileString(strSec, "musicPath", txtMusicPath.Text.Trim(), strFilePath);

WritePrivateProfileString(strSec, "imagePath", txtImagePath.Text.Trim(), strFilePath);

MessageBox.Show("保存成功!");

grbSet.Visible = false;

pnlMusic.Visible = true;

} catch (Exception ex) {

MessageBox.Show(ex.Message);

return;

}

}

//返回主界面

private void btnReturn_Click(object sender, EventArgs e) {

grbSet.Visible = false;

pnlMusic.Visible = true;

}

#endregion

#region  从列表中读取选中第一列的值,最上面显示歌曲名称

private void listViewAll_SelectedIndexChanged(object sender, EventArgs e) {

if (listViewAll.SelectedIndices != null && listViewAll.SelectedIndices.Count > 0) {

ListView.SelectedIndexCollection c = listViewAll.SelectedIndices;

string suoyin = listViewAll.Items[c[0]].Text;

nowcount = Convert.ToInt32(suoyin) - 1;

//改变歌曲名称

labName.Text = musicNameList[Convert.ToInt32(suoyin) - 1].ToString();

try {

//显示图片

pbPicture.Image = new Bitmap(strImage + "\\" + imageNameList[Convert.ToInt32(suoyin) - 1].ToString());

ReadTXT(labGeci);

} catch (Exception) {

}

}

}

#endregion

#region Listview 双击事件,播放音乐

private void listViewAll_DoubleClick(object sender, EventArgs e) {

axWindowsMediaPlayer1.URL = strMusic + "\\" + labName.Text;

axWindowsMediaPlayer1.Ctlcontrols.play();

//歌词

ReadTXT(labGeci);

}

#endregion

#region 播放/暂停

private void btnStop_Click(object sender, EventArgs e) {

try {

#region SoundPlayer 只可以播放波形文件(.wav格式)

//System.Media.SoundPlayer sp=new System.Media.SoundPlayer();

////SoundPlayer sp = new SoundPlayer();

//sp.SoundLocation = strMusic +"\\"+ labName.Text;

//sp.Load();

//sp.Play();

#endregion

if (btnStart.Text == ">") {

if (radOneYes.Checked == true) {

axWindowsMediaPlayer1.URL = strMusic + "\\" + abcMusic;

} else {

//播放

axWindowsMediaPlayer1.URL = strMusic + "\\" + labName.Text;

}

//记录播放位置

if (tbMusic.Value != 0) {

axWindowsMediaPlayer1.Ctlcontrols.currentPosition = tbMusic.Value;

}

axWindowsMediaPlayer1.Ctlcontrols.play();

//歌词

ReadTXT(labGeci);

timerGeci.Enabled = true;

timer1.Enabled = true;

btnStart.Text = "||";

//透明层显示

pnlTouMing.Visible = false;

#region 一些属性

//string Duration = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("Duration");//持续时间(秒)

//string Title = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("Title");//媒体标题

//string Author = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("Author");//艺术家

//string Copyright = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("Copyright");//版权信息

//string Description = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("Description");//媒体内容描述

//string FileSize = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("FileSize");//文件大小

//string FileType = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("FileType");//文件类型

//string sourceURL = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("sourceURL");//原始地址

//MessageBox.Show("持续时间:" + Duration + "||" + "媒体标题:" + Title + "||" + "艺术家:" + Author + "||" + "版权信息:" + Copyright + "||" + "媒体内容描述:" + Description + "||" + "文件大小:" + FileSize + "||" + "文件类型:" + FileType + "||" + "原始地址:" + sourceURL);

#endregion

return;

}

if (btnStart.Text == "||") {

//暂停

axWindowsMediaPlayer1.Ctlcontrols.pause();

timerGeci.Enabled = false;

timer1.Enabled = false;

btnStart.Text = ">";

//透明层显示

pnlTouMing.Visible = true;

return;

}

} catch (Exception ex) {

MessageBox.Show(ex.Message);

return;

}

}

#endregion

#region 上一曲

private void btnUp_Click(object sender, EventArgs e) {

for (int i = 0; i < allcount; i++) {

if (musicNameList[i].ToString() == labName.Text) {

nowcount = i;

}

}

//当前行所有大于0,则上一曲的索引最新为0

if (nowcount > 0) {

labName.Text = musicNameList[nowcount - 1].ToString();

//显示图片

pbPicture.Image = new Bitmap(strImage + "\\" + imageNameList[nowcount - 1].ToString());

//显示歌词

ReadTXT(labGeci);

axWindowsMediaPlayer1.URL = strMusic + "\\" + labName.Text;

axWindowsMediaPlayer1.Ctlcontrols.play();

//歌词

ReadTXT(labGeci);

} else {

return;

}

}

#endregion

#region 下一曲

private void btnNext_Click(object sender, EventArgs e) {

for (int i = 0; i < allcount; i++) {

if (musicNameList[i].ToString() == labName.Text) {

nowcount = i;

}

}

if (nowcount < allcount - 1) {

labName.Text = musicNameList[nowcount + 1].ToString();

//显示图片

pbPicture.Image = new Bitmap(strImage + "\\" + imageNameList[nowcount + 1].ToString());

//显示歌词

ReadTXT(labGeci);

axWindowsMediaPlayer1.URL = strMusic + "\\" + labName.Text;

axWindowsMediaPlayer1.Ctlcontrols.play();

//歌词

ReadTXT(labGeci);

} else {

return;

}

}

#endregion

#region 停止

private void btnStop_Click_1(object sender, EventArgs e) {

axWindowsMediaPlayer1.Ctlcontrols.stop();

// axWindowsMediaPlayer1.URL = strMusic + "\\" + labName.Text;

btnStart.Text = ">";

tbMusic.Value = 0;

labDateNow.Text = "00:00";

}

#endregion

#region 播放进度条

//进度条

private void timer1_Tick(object sender, EventArgs e) {

//axWindowsMediaPlayer1.URL = strMusic + "\\" + labName.Text;

if (axWindowsMediaPlayer1.currentMedia != null) {

tbMusic.Maximum = Convert.ToInt32(axWindowsMediaPlayer1.currentMedia.duration);

tbMusic.Minimum = 0;

tbMusic.Value = Convert.ToInt32(axWindowsMediaPlayer1.Ctlcontrols.currentPosition);

//字符串类型的当前时间

labDateNow.Text = axWindowsMediaPlayer1.Ctlcontrols.currentPositionString.ToString();

//字符串类型的时长

labDateAll.Text = axWindowsMediaPlayer1.currentMedia.durationString.ToString();

}

//是否循环播放

if (chkXunHuan.Checked == true) {//判断是单曲循环还是多曲循环

if (radOneYes.Checked == true) {//单曲循环

//如果进度条到达最大位置,则设置为最小值

if (tbMusic.Value == 0) {

btnStart.Text = ">";

btnStart.PerformClick();

}

} else { //多曲循环

//如果进度条到达最大位置,并且这一曲不是最好一曲就播放下一曲

if (tbMusic.Value == tbMusic.Maximum && axWindowsMediaPlayer1.currentMedia.getItemInfo("Title") != musicNameList[musicNameList.Count - 1].ToString()) {

btnNext.PerformClick();

}

}

}

}

#endregion

#region 改变音量的大小

private void tbVoice_Scroll(object sender, EventArgs e) {

this.axWindowsMediaPlayer1.settings.volume = this.tbVoice.Value;

}

#endregion

#region 快进、快退

//快进,卡

private void btnUpup_Click(object sender, EventArgs e) {

axWindowsMediaPlayer1.Ctlcontrols.fastReverse();

}

//快退

private void btnNextnext_Click(object sender, EventArgs e) {

axWindowsMediaPlayer1.Ctlcontrols.fastForward();

}

#endregion

#region 改变播放进度

private void tbMusic_Scroll(object sender, EventArgs e) {

axWindowsMediaPlayer1.Ctlcontrols.currentPosition = tbMusic.Value;

//this.axWindowsMediaPlayer1.currentMedia.setItemInfo("volume", 60);

}

#endregion

#region 点击声音按钮,音量是否显示

private void pbVoice_Click(object sender, EventArgs e) {

if (tbVoice.Visible == false) {

tbVoice.Visible = true;

return;

}

if (tbVoice.Visible == true) {

tbVoice.Visible = false;

return;

}

}

#endregion

#region 歌曲名称滚动字幕

private void timerFont_Tick(object sender, EventArgs e) {

labName.Left = labName.Left - 3;

if (labName.Right < 0) {

labName.Left = pnlFontScoll.Width;

}

}

#endregion

#region 单曲循环、多曲循环   显示

private void chkXunHuan_CheckedChanged(object sender, EventArgs e) {

if (chkXunHuan.Checked == true) {

pnlXunHuan.Visible = true;

return;

} else {

pnlXunHuan.Visible = false;

return;

}

}

private void chkXunHuan_MouseMove(object sender, MouseEventArgs e) {

if (chkXunHuan.Checked == true) {

pnlXunHuan.Visible = true;

return;

}

}

private void pnlXunHuan_MouseMove(object sender, MouseEventArgs e) {

if (chkXunHuan.Checked == true) {

int a = MouseInPanel(pnlXunHuan);

if (a == 1) {

pnlXunHuan.Visible = true;

} else {

pnlXunHuan.Visible = false;

}

}

}

#region 判断鼠标位置是否在一个层上

private int MouseInPanel(Panel panel) {

//    当前的屏幕除任务栏外的工作域大小

//    this.Width = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;

//    this.Height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;

//    当前的屏幕包括任务栏的工作域大小

//    this.Width=System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;

//    this.Height=System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;

// Cursor.Position.X;//鼠标的坐标,相对于屏幕

// Cursor.Position.Y;

int kuan = pnlMusic.Width;

int gao = pnlMusic.Height;

int x = Cursor.Position.X - (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width-kuan) / 2;

int y = Cursor.Position.Y - (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height-gao) / 2;

int px = panel.Location.X;//panel位置

int py = panel.Location.Y;

int pw = panel.Width;//panel宽和高

int ph = panel.Height;

if (x > px && y > py && x < px + pw && y < py + ph) {

return 1;

} else {

return 0;

}

}

#endregion

//获取窗体鼠标的位置,但是不执行

private void LenMusic_MouseMove(object sender, MouseEventArgs e) {

//mx = e.X;

//my = e.Y;

//label2.Text = e.X + "," + e.Y;

//mx = MousePosition.X - this.Width;

//my = MousePosition.Y - this.Height;

}

#endregion

#region 单曲被选中,把这首歌的名称赋值给一个变量

private void radOneYes_CheckedChanged(object sender, EventArgs e) {

if (radOneYes.Checked == true) {

abcMusic = labName.Text;

}

}

#endregion

//待解决问题,选中单曲循环时,会自动播放

#region 点击透明层上的按钮  播放

private void pbStart_Click(object sender, EventArgs e) {

if (btnStart.Text == ">") {

if (radOneYes.Checked == true) {

axWindowsMediaPlayer1.URL = strMusic + "\\" + abcMusic;

} else {

//播放

axWindowsMediaPlayer1.URL = strMusic + "\\" + labName.Text;

}

//记录播放位置

if (tbMusic.Value != 0) {

axWindowsMediaPlayer1.Ctlcontrols.currentPosition = tbMusic.Value;

}

axWindowsMediaPlayer1.Ctlcontrols.play();

timer1.Enabled = true;

btnStart.Text = "||";

//透明层显示

pnlTouMing.Visible = false;

return;

}

if (btnStart.Text == "||") {

//暂停

axWindowsMediaPlayer1.Ctlcontrols.pause();

timer1.Enabled = false;

btnStart.Text = ">";

//透明层显示

pnlTouMing.Visible = false;

}

return;

}

#endregion

#region 点击显示、关闭透明层

private void pbPicture_Click(object sender, EventArgs e) {

if (pnlTouMing.Visible == true) {

pnlTouMing.Visible = false;

} else {

if (btnStart.Text == ">") {

pbStart.Image = new Bitmap(Application.StartupPath + "\\image\\start.png");

} else {

pbStart.Image = new Bitmap(Application.StartupPath + "\\image\\start2.png");

}

pnlTouMing.Visible = true;

}

}

#endregion

#region 双击图片铺满屏幕、双击铺满窗体

private void pbPicture_DoubleClick(object sender, EventArgs e) {

#region 双击图片铺满窗体(设置窗体层的背景图片),效果不好

//pnlMusic.BringToFront();

//pnlMusic.BackgroundImage = System.Drawing.Image.FromFile(strImage+"\\" + imageNameList[nowcount].ToString());

////设置背景图片自动适应

//pnlMusic.BackgroundImageLayout = ImageLayout.Stretch;

#endregion

#region 双击,图片全屏

if (MaxOrNo == false) {//不是最大化

//把窗体设置为全屏

this.WindowState = FormWindowState.Maximized;

pnlMusic.Dock = System.Windows.Forms.DockStyle.Fill; //设置层的格式为充满

pbPicture.Parent = this.pnlMusic; //设置图片的父容器为层

pbPicture.Location = new System.Drawing.Point(0, 0);//把pbPicture的坐标设置为(0,0)

pbPicture.BringToFront(); //把pbPicture设置为顶层

//设置图片的宽和高

pbPicture.Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;

pbPicture.Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;

//设置播放按钮的位置

pnlTouMing.Location = new System.Drawing.Point(pbPicture.Width / 2, pbPicture.Height / 2 - 300);

MaxOrNo = true;//改变状态

} else { //是最大化

//this.WindowState = FormWindowState.Normal;

//pbPicture = pb;

//pnlMusic.SendToBack();

//pnlMusic.Dock = System.Windows.Forms.DockStyle.None;

MaxOrNo = false;//改变状态

}

#endregion

}

#endregion

#region 是否显示歌词

private void chkGeCi_CheckedChanged(object sender, EventArgs e) {

if (chkGeCi.Checked == true) {

labGeci.Visible = true;

timerGeci.Enabled = true;

} else {

labGeci.Visible = false;

timerGeci.Enabled = false;

}

}

#endregion

#region 读取TXT 文件

private void ReadTXT(Label lab) {

txtn = 0;//每次读取txt时,清空上一个TXT的行数

string strTxtAll = "";

string abc = strGeci + "\\" + geciNameList[nowcount].ToString();

FileStream fs = new FileStream(abc, FileMode.Open, FileAccess.Read, FileShare.None);

StreamReader sr = new StreamReader(fs, Encoding.GetEncoding("GB2312"));

string line = sr.ReadLine();

strTxtAll = line + "\r\n";

for (int ac = 0; line != null; ac++) {

line = sr.ReadLine();

txtn++;

strTxtAll += line + "\r\n";

}

lab.Text = strTxtAll;

lab.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

sr.Close();

fs.Close();

}

#endregion

#region 歌词滚动

private void timerGeci_Tick(object sender, EventArgs e) {

//获取步长

//int n = 0;//步长

//if (axWindowsMediaPlayer1.currentMedia != null) {

//    double nAll = axWindowsMediaPlayer1.currentMedia.duration; //获取当前歌曲的时长

//    ReadTXT(labGeci);//给Label赋值

//    //计算时是以毫秒为单位的 Interval=1000;

//    n = Convert.ToInt32(labGeci.Height / nAll);

//    //MessageBox.Show(labGeci.Height + "," + nAll.ToString());

//    return;

//}

//滚动

labGeci.Top = labGeci.Top - 3;

if (labGeci.Bottom < 0) {

labGeci.Top = pbPicture.Width;

}

}

#endregion

}

}


Winform Windows Media Player 简易播放器

时间: 2024-10-14 04:35:31

Winform Windows Media Player 简易播放器的相关文章

基于MFC的Media Player的播放器的制作(1---播放器界面的布局)

|   版权声明:本文为博主原创文章,未经博主允许不得转载. 通过上面的一些预备知识,我们现在就可以自己来制作基于MFC的播放器了,接下来我们讲的是使用MFC制作我们播放器 的界面. 首先,我们我们打开VC++ 6.0.找到工具条:  文件 ---> 新建--->在接下的操作根据图片来 上面的操作完成之后,我们可以在我们设置的保存路径处,找到我们的过程文件夹,并且可以看到VC++6.0的面板了. 如下图: 接下来,介绍界面组件的添加:如图操作 如上图将所有的组件添加好,并设置好ID和名称,我的

winform播放视频(windows media player)

1.找到windows media player 工具箱常规下边右键,右键弹窗点击“选择项”,选择工具箱窗口点击“COM组件”,找到 Windows Media Player 勾选,点击确定 2.使用windows media player 直接将windows media player控件拖动到窗体上, 3.属性 (1)fullScreen:满屏 (2)enableContextMenu:是否显示右键菜单 (3)stretchToFit :非全屏状态时是否伸展到最佳大小 (4)uMode: 播

windows media player 播放视频

一.新建windows应用程序项目,添加vedioForm窗体 二.在com组件中找到windows media player,添加引用 三.代码如下: 1 public partial class VedioForm : Form 2 { 3 private AxWMPLib.AxWindowsMediaPlayer axWindowsMediaPlayer1; 4 public VedioForm() 5 { 6 InitializeComponent(); 7 InitVedio(); 8

Windows media player控件第二次播放时无法全屏

新建MFC工程,插入windows media player control,属性设置fullscreen为true,设置好URL参数. 添加CWMPPlayer4,CWMPControls3类. 控件绑定关联变量CWMPPlayer4 m_player并设CWMPControls3 m_control = m_player.get_controls(); 为了达到循环播放的目的,响应PlayStateChange消息,消息处理函数中是如下两句: m_control.play(); m_play

Java通过Ole调用Windows Media Player,部分控件属性调用方法

其实Java并不擅长做这类开发和研究,尤其是媒体影音是Java的弱项.但是为了项目,只能丧心病狂了. 起初在网络上找到了一个可行的调用类,并有一个调用实例,相信有过这方面经验都有下载过,文件名就叫WMP.但是这个还不能满足我现在做的这个项目的功能需求,里面缺少很多官方文档的空间属性方法,其中就包含我需要的. 最开始的解决方法是在网络上载找找看,希望能找到完整的类包,但是相关的资源都是大家炒来炒去,都一样,没有带来什么帮助,久寻未果就放弃了. 其后有看到c++调用Windows Media Pla

如何在Windows中打开多个Windows Media Player

博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:如何在Windows中打开多个Windows Media Player. 如何在Windows中打开多个Windows Media Player

Windows Media Player 打不开怎么办

1. 右键VS工具箱的空白处; 2. 打开工具箱, 选择com组件→找到windows media player 3. 如果这里没有发现 windows Media Player怎么办? , 以win10为例说明, 打开小娜搜一搜, 4. 双击后发现打不开? 打开控制面板→程序→启动或关闭windows功能→把下图的两个√去掉 5. 然后必须重启计算机, 重启后, 再到那里把两个√给勾上, 然后确定, 他会自动安装; 6. 安装完成后, 就会在com组件中发现windows media play

winform下的简易播放器

编写这个播放器,遇到很多问题,比如目前只实现了wav音频文件的播放,而对于这个图中中间所标注的按钮 不能实现让其暂停的功能,同时当点击的时候,让其文本变为"?",对于这部分功能不知道选定该按钮时的属性是 如何,所以还需继续完善 播放器代码 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawin

ffmpeg实战教程(二)用SDL播放YUV,并结合ffmpeg实现简易播放器

我们先实现用SDL播放YUV数据 先来了解一下基本概念 SDL基本函数: [初始化] * SDL_Init(): 初始化SDL. * SDL_CreateWindow(): 创建窗口(Window). * SDL_CreateRenderer(): 基于窗口创建渲染器(Render). * SDL_CreateTexture(): 创建纹理(Texture). [循环渲染数据] * SDL_UpdateTexture(): 设置纹理的数据. * SDL_RenderCopy(): 纹理复制给渲染