1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Viet chuong trinh play nhac tủ tài liệu bách khoa

4 63 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Nội dung

Tơi học C# có viết ứng dụng nghe nhạc xem phim nhỏ Mới học được, Mong bạn góp ý thảo luận, Chay tốt tốn chục kb thơi, Nhưng có điều mở files nhạc có tên gõ unicode khơng chạy code sử dụng API Import winmm.dll Nhưng chay khơng chơi hát với tên có kí tự unicode hè Bà có biết nói giùm code ứng dụng Có góp ý using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace MultiPlay { public partial class Form1 : Form { private bool filedangmo = false; private bool lapkhong = false; private bool tamdung = false; public Form1() { InitializeComponent(); } [DllImport("winmm.dll")] public static extern long mciSendString(string caulenh, StringBuilder strbuilder, int chieudai, IntPtr tinhieu); private StringBuilder sbf = new StringBuilder(); public string trangthai() { mciSendString("status mediafile mode", sbf, sbf.Capacity, IntPtr.Zero); //MessageBox.Show(sbf.ToString()); return sbf.ToString(); } private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (trangthai() == "playing") { lenh = "close mediafile"; this.pictureBox2.Visible = false; mciSendString(lenh, null, 0, IntPtr.Zero); openFileDialog1.Title = "Chọn Files nhạc (*.mpg,*.avi,*.dat)"; openFileDialog1.Filter = "Media File(*.mpg,*.dat,*.avi,*.wmv,*.wav,*.mp3)|*.wav;* mp3;*.mpg;*.dat;*.avi;*.wmv"; openFileDialog1.ShowDialog(); filedangmo = true; } else { //if (trangthai() == "stopper") //{ // lenh = "close mediafile"; // mciSendString(lenh, null, 0, IntPtr.Zero); // openFileDialog1.Title = "Chọn Files nhạc (*.mpg,*.avi,*.dat)"; // openFileDialog1.Filter = "Media File(*.mpg,*.dat,*.avi,*.wmv,*.wav,*.mp3)|*.wav;* mp3;*.mpg;*.dat;*.avi;*.wmv"; // openFileDialog1.ShowDialog(); // filedangmo = true; //} lenh = "close mediafile"; mciSendString(lenh, null, 0, IntPtr.Zero); openFileDialog1.Title = "Chọn Files nhạc (*.mpg,*.avi,*.dat)"; openFileDialog1.Filter = "Media File(*.mpg,*.dat,*.avi,*.wmv,*.wav,*.mp3)|*.wav;* mp3;*.mpg;*.dat;*.avi;*.wmv"; openFileDialog1.ShowDialog(); filedangmo = true; } } string lenh; private void button1_Click(object sender, EventArgs e) { lenh = "open \"" + this.openFileDialog1.FileName + "\" type mpegvideo alias mediafile style child parent "+this.pictureBox1.Handle.ToInt32(); mciSendString(lenh, null, 0, IntPtr.Zero); lenh = "put mediafile window at 0 " + this.pictureBox1.Width + " " + this.pictureBox1.Height; if (filedangmo) { this.Text = openFileDialog1.FileName; lenh = "play mediafile"; mciSendString(lenh, null, 0, IntPtr.Zero); this.pictureBox2.Visible = true; } else { MessageBox.Show("Chưa mở file"); } } private void fullScreenToolStripMenuItem_Click(object sender, EventArgs e) { hamfullscreen(); } private void button2_Click(object sender, EventArgs e) { lenh = "close mediafile"; mciSendString(lenh, null, 0, IntPtr.Zero); filedangmo = true; this.pictureBox2.Visible = false; } private void closeToolStripMenuItem_Click(object sender, EventArgs e) { this.Close(); filedangmo = false; } private void cửaSổRiêngToolStripMenuItem_Click(object sender, EventArgs e) { hamcuaso(); } private void button3_Click(object sender, EventArgs e) { if(trangthai().Equals("stopper")){ lenh = "play mediafile"; mciSendString(lenh, null, 0, IntPtr.Zero); }else { lenh = "stop mediafile"; mciSendString(lenh, null, 0, IntPtr.Zero); } } private void pictureBox1_Click(object sender, EventArgs e) { hamfullscreen(); } public void hamfullscreen() { lenh = "stop mediafile"; mciSendString(lenh, null, 0, IntPtr.Zero); lenh = "play mediafile fullscreen"; mciSendString(lenh, null, 0, IntPtr.Zero); } private void chạyToolStripMenuItem_Click(object sender, EventArgs e) { hamcuaso(); } private void hamcuaso() { lenh = "close mediafile"; mciSendString(lenh, null, 0, IntPtr.Zero); lenh = "open \"" + this.openFileDialog1.FileName + "\" type mpegvideo alias mediafile "; mciSendString(lenh, null, 0, IntPtr.Zero); lenh = "play mediafile"; mciSendString(lenh, null, 0, IntPtr.Zero); } } } WEB hay giới thiệu người: http://www.henho.com ... " " + this.pictureBox1.Height; if (filedangmo) { this.Text = openFileDialog1.FileName; lenh = "play mediafile"; mciSendString(lenh, null, 0, IntPtr.Zero); this.pictureBox2.Visible = true; } else... private void button3_Click(object sender, EventArgs e) { if(trangthai().Equals("stopper")){ lenh = "play mediafile"; mciSendString(lenh, null, 0, IntPtr.Zero); }else { lenh = "stop mediafile"; mciSendString(lenh,... void hamfullscreen() { lenh = "stop mediafile"; mciSendString(lenh, null, 0, IntPtr.Zero); lenh = "play mediafile fullscreen"; mciSendString(lenh, null, 0, IntPtr.Zero); } private void chạyToolStripMenuItem_Click(object

Ngày đăng: 07/11/2019, 20:35

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w