📄 mp3.cs
字号:
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;
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.previous();
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_all_Click(object sender, EventArgs e)
{
lab_all.BackColor = Color.Thistle;
lab_one_cycle.BackColor = Color.DarkSlateBlue;
bool_cyle = true;
}
private void lab_one_cycle_Click(object sender, EventArgs e)
{
lab_all.BackColor = Color.DarkSlateBlue;
lab_one_cycle.BackColor = Color.Thistle;
bool_cyle = false;
}
private void lab_ctl_Click(object sender, EventArgs e)
{
if (bool_ctl_open == false && bool_ctl_open_gecipanel == false)
{
bool_ctl_open = true;
lab_no_sound.Visible = true;
btn_select_play.Visible = true;
listBox1.Visible = true;
btn_add_dir.Visible = true;
btn_add_one.Visible = true;
btn_move_one.Visible = true;
button4.Visible = true;
btn_help.Visible = true;
lab_ctl.BackColor = Color.Thistle;
}
else
if (bool_ctl_open == false && bool_ctl_open_gecipanel == true)
{
bool_ctl_open = true;
lab_no_sound.Visible = true;
btn_select_play.Visible = true;
listBox1.Visible = true;
btn_add_dir.Visible = true;
btn_add_one.Visible = true;
btn_move_one.Visible = true;
button4.Visible = true;
btn_help.Visible = true;
lab_ctl.BackColor = Color.Thistle;
pictureBox2.Location = new Point(318,0);
label2.Location = new Point(pictureBox2.Location.X+18,pictureBox2.Location.Y+9);
label3.Location = new Point(pictureBox2.Location.X+124,pictureBox2.Location.Y+9);
listBox2.Location = new Point(pictureBox2.Location.X+18,pictureBox2.Location.Y+34);
}
else
if (bool_ctl_open == true && bool_ctl_open_gecipanel == true)
{
bool_ctl_open = false;
btn_select_play.Visible = false;
listBox1.Visible = false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -