i've come across trouble again this time.
my problem :
for now i place my audiovideoplayback Video in a panel.Code:i want to make a Movie Player using Micorost.directx.audiovideoplayback.dll whats make it trouble is => i want to double click to make it fullscreen.. or i can say do an event.
but when i do double click even on the panel, it wont work..
so i was wondering if there any way to make a panel can be double clicked even if a component covered by other component.
i guess word alone wont help
so here the code
this was made 100% pure coding. except the timer. i dragdrop it
the timer only used to make the seekbar to follow the following position/max position of video
why i use directx instead of wmplib?
because directx can play all type of video while wmplib cant.
Code: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; // take on add reference -> browse [C:/windows/assembly/gac/microsoft.directx.audiovideoplayback/audiovideoplayback.dll] using Microsoft.DirectX.AudioVideoPlayback; namespace DvMoviePlayer { public partial class Form1 : Form { /* * INDEX * Form Load DMP001 * InitializeRestComponent DMP002 * autoResize DMP003 * createNewVideo DMP004 * videoFrame_dragDrop DMP005 * videoFrame_dragEnter DMP006 * Form1_Resize DMP007 * timer1_Tick DMP008 */ /* private void test() { OpenFileDialog result = new OpenFileDialog(); result.Filter = "Video Files | *.avi;*.flv;*.mp4;*.wmv"; result.Multiselect = false; result.ShowDialog(); createNewVideo(result.FileName); } */ public Form1() { InitializeComponent(); InitializeRestComponent(); } private Panel videoFrame = new Panel(); private Video video; private TrackBar seek_bar = new TrackBar(); private Label duration = new Label(); private void Form1_Load(object sender, EventArgs e) {//DMP001 } private void InitializeRestComponent() {//DMP002 autoResize(); videoFrame.BackColor = Color.Black; videoFrame.BorderStyle = BorderStyle.Fixed3D; videoFrame.AllowDrop = true; videoFrame.DragDrop += new DragEventHandler(this.videoFrame_dragDrop); videoFrame.DragEnter += new DragEventHandler(this.videoFrame_dragEnter); videoFrame.DoubleClick += new EventHandler(this.videoFrame_doubleClick); this.Controls.Add(videoFrame); seek_bar.LargeChange = 0; seek_bar.SmallChange = 0; seek_bar.TickStyle = TickStyle.Both; seek_bar.TabStop = false; seek_bar.TickFrequency = 0; this.Controls.Add(seek_bar); duration.ForeColor = Color.White; duration.Font = new Font("Segoe UI", 8, FontStyle.Regular); this.Controls.Add(duration); timer1.Start(); } private void autoResize() {//DMP003 videoFrame.SetBounds(0,0,this.Width-16,this.Height-90); if (video != null) video.Size = videoFrame.Size; seek_bar.SetBounds(0,this.Height-90,this.Width-16,50); duration.SetBounds(this.Width-100,this.Height-75,100,15); } private void createNewVideo(String path) {//DMP004 try { video = new Video(path); video.Owner = videoFrame; seek_bar.Maximum = (int)video.Duration; video.Play(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void videoFrame_dragDrop(object sender, DragEventArgs e) {//DMP005 string[] res = (string[])e.Data.GetData(DataFormats.FileDrop); String ext = res[0].Substring(res[0].LastIndexOf(".")+1); if (ext.ToLower().Equals("avi") || ext.ToLower().Equals("flv") || ext.ToLower().Equals("mp4") || ext.ToLower().Equals("wmv") || ext.ToLower().Equals("mkv")) { createNewVideo(res[0]); } } private void videoFrame_dragEnter(object sender, DragEventArgs e) {//DMP006 if (e.Data.GetDataPresent(DataFormats.FileDrop)) { e.Effect = DragDropEffects.Copy; } else { e.Effect = DragDropEffects.None; } } private void Form1_Resize(object sender, EventArgs e) {//DMP007 //autoResize(); } private void timer1_Tick(object sender, EventArgs e) {//DMP008 autoResize(); if (video != null) { seek_bar.Value = (int)video.CurrentPosition; duration.Text = video.Duration.ToString(); } } private void videoFrame_doubleClick(object sender, EventArgs e) { MessageBox.Show("Test"); if (video != null) video.Fullscreen = true; } } }




Reply With Quote