没有合适的资源?快使用搜索试试~ 我知道了~
用c#写的音乐播放器的源代码可以参考一下
资源详情
资源评论
资源推荐
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using AxWMPLib;
using System.IO;
namespace MyMp3Baby
{
public partial class Mp3 : Form
{
private int num_old_x_length = 0;
private int num_old_y_length = 0;
private int num_new_x_length = 0;
private int num_new_y_length = 0;
private bool bool_cyle = true;
private bool bool_ctl_open = false;
private bool bool_ctl_open_gecipanel = false;
private double num_music_time = 0;
private int num_sound_value = 0;
private bool bool_no_sound = false;
private string str_load_dir = "";
private bool bool_is_playing = false;
private int num_ctl_lab_text = 0;
private int num_ctl_banks = 1;
private bool bool_ever_played_music = false;
private string[] str_geci = new string[100];
public Mp3()
{
File.AppendAllText("LoadMusic.txt","");
InitializeComponent();
str_load_dir = File.ReadAllText("LoadMusic.txt");
if (str_load_dir != "")
Loadmusics();
}
#region 拖动窗口
void pictureBox1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
timer1.Enabled = false;
}
void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs
e)
{
if (e.Button == MouseButtons.Left)
{
num_old_x_length = Control.MousePosition.X - this.Location.X;
num_old_y_length = Control.MousePosition.Y - this.Location.Y;
timer1.Enabled = true;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (sender == timer1)
{
num_new_x_length = Control.MousePosition.X - this.Location.X;
num_new_y_length = Control.MousePosition.Y - this.Location.Y;
this.Location = new Point(this.Location.X + num_new_x_length -
num_old_x_length, this.Location.Y + num_new_y_length - num_old_y_length);
}
}
#endregion
private void lab_play_Click(object sender, EventArgs e)
{
if (axWindowsMediaPlayer1.currentPlaylist.count > 0)
{
if (bool_is_playing == false)
{
axWindowsMediaPlayer1.Ctlcontrols.play();
lab_mp3_name.Text = axWindowsMediaPlayer1.currentMedia.name;
lab_play.Text = "Paus";
bool_is_playing = true;
num_music_time = 0;
timer2.Enabled = true;
is_playing();
timer3.Enabled = true;
progressBar1.Value =(int)axWindowsMediaPlayer1.Ctlcontrols.currentPosition;
lab_xx_xx.Text = axWindowsMediaPlayer1.currentMedia.durationString;
bool_ever_played_music = true;
listBox2.Items.Clear();
for (int k = 0; k < str_geci.Length; k++)
str_geci[k] = "";
}
else
{
axWindowsMediaPlayer1.Ctlcontrols.pause();
lab_play.Text = "Play";
bool_is_playing = false;
timer2.Enabled = false;
timer3.Enabled = false;
progressBar1.Value = (int)axWindowsMediaPlayer1.Ctlcontrols.currentPosition;
lab_xx_xx.Text = axWindowsMediaPlayer1.currentMedia.durationString;
}
}
else
MessageBox.Show("请先添加歌曲!","警告");
}
private void lab_stop_Click(object sender, EventArgs e)
{
if (axWindowsMediaPlayer1.currentPlaylist.count > 0)
{
axWindowsMediaPlayer1.Ctlcontrols.stop();
lab_mp3_name.Text = "MusciBaby播放器";
lab_play.Text = "Play";
bool_is_playing = false;
progressBar1.Value = 0;
lab_xx_xx.Text = "00:00";
lab_now_position.Text = "00:00";
listBox2.Items.Clear();
for (int k = 0; k < str_geci.Length; k++)
str_geci[k] = "";
}
else
MessageBox.Show("请先添加歌曲!", "警告");
}
private void lab_next_Click(object sender, EventArgs e)
{
if (axWindowsMediaPlayer1.currentPlaylist.count > 0)
{
if (listBox1.Items.Count == 1)
{
axWindowsMediaPlayer1.Ctlcontrols.play();
lab_play.Text = "Pause";
bool_is_playing = true;
lab_mp3_name.Text = axWindowsMediaPlayer1.currentMedia.name;
num_music_time = 0;
timer2.Enabled = true;
is_playing();
progressBar1.Value = (int)axWindowsMediaPlayer1.Ctlcontrols.currentPosition;
lab_xx_xx.Text = axWindowsMediaPlayer1.currentMedia.durationString;
listBox2.Items.Clear();
for (int k = 0; k < str_geci.Length; k++)
str_geci[k] = "";
}
else
{
if (listBox1.SelectedItems.Count > 0 &&bool_ever_played_music==true)
{
axWindowsMediaPlayer1.Ctlcontrols.next();
lab_mp3_name.Text = axWindowsMediaPlayer1.currentMedia.name;
num_music_time = 0;
timer2.Enabled = true;
is_playing();
progressBar1.Value =
(int)axWindowsMediaPlayer1.Ctlcontrols.currentPosition;
lab_xx_xx.Text = axWindowsMediaPlayer1.currentMedia.durationString;
listBox2.Items.Clear();
for (int k = 0; k < str_geci.Length; k++)
str_geci[k] = "";
}
}
}
else
MessageBox.Show("请先添加歌曲!", "警告");
}
private void lab_pre_Click(object sender, EventArgs e)
{
if (axWindowsMediaPlayer1.currentPlaylist.count > 0)
{
if (listBox1.Items.Count == 1)
{
axWindowsMediaPlayer1.Ctlcontrols.play();
lab_play.Text = "Pause";
bool_is_playing = true;
lab_mp3_name.Text = axWindowsMediaPlayer1.currentMedia.name;
num_music_time = 0;
timer2.Enabled = true;
is_playing();
progressBar1.Value = (int)axWindowsMediaPlayer1.Ctlcontrols.currentPosition;
剩余22页未读,继续阅读
gusuchengnan
- 粉丝: 1
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 电力场景设备漏油检测数据集VOC+YOLO格式338张1类别.7z
- 基于yolov8+pyqt5实现精美界面支持图片视频和摄像检测源码.zip
- 用C语言为母亲节献上一份特别的祝福.zip
- LCD1602液晶显示屏的深入探索与实用指南.zip
- 基于Matlab人脸肤色定理的教师人数统计+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab霍夫曼变换的表盘读数识别+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab火灾烟雾检测源码带GUI界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的恶劣天气交通标志识别系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的霍夫曼变换的表盘示数识别+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的车道线识别系统 +源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0