Created
March 16, 2018 12:49
-
-
Save Fhernd/f68fd276ace7c3eb24bace839ccaa44b to your computer and use it in GitHub Desktop.
OrtizOL. Reproducción de vídeo. C#.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Windows.Forms; | |
using QuartzTypeLib; | |
namespace R812ReproducirVideo | |
{ | |
public partial class Principal : Form | |
{ | |
// Constante del estilo de ventana: | |
private const int WS_CHILD = 0x40000000; | |
private const int WS_CHIPCHILDREN = 0x000000; | |
// Referencia a la interfaz de control multimedia> | |
private IMediaControl mc = null; | |
// Referncia a la ventana de vídeo sobre el formulario: | |
private IVideoWindow ventanaVideo = null; | |
public Principal() | |
{ | |
InitializeComponent(); | |
} | |
private void btnReproducirVideo_Click(object sender, EventArgs e) | |
{ | |
OpenFileDialog ofd = new OpenFileDialog(); | |
ofd.Filter = "Media Files|*.mpg;*.avi;*.wma;*.mov;*.wav;*.mp3;*.mp4|All Files|*.*"; | |
if (DialogResult.OK == ofd.ShowDialog()) | |
{ | |
if (mc != null) | |
{ | |
mc.Stop(); | |
} | |
FilgraphManager grapManager = new FilgraphManager(); | |
grapManager.RenderFile(ofd.FileName); | |
try | |
{ | |
ventanaVideo = (IVideoWindow) grapManager; | |
ventanaVideo.Owner = (int) pbxVideo.Handle; | |
ventanaVideo.WindowStyle = WS_CHILD | WS_CHIPCHILDREN; | |
ventanaVideo.SetWindowPosition( | |
pbxVideo.ClientRectangle.Left, | |
pbxVideo.ClientRectangle.Top, | |
pbxVideo.ClientRectangle.Width, | |
pbxVideo.ClientRectangle.Height | |
); | |
} | |
catch | |
{ | |
// Gestión eventual de errores. | |
} | |
mc = (IMediaControl) grapManager; | |
mc.Run(); | |
} | |
} | |
private void pbxVideo_SizeChanged(object sender, EventArgs e) | |
{ | |
if (ventanaVideo != null) | |
{ | |
try | |
{ | |
ventanaVideo.SetWindowPosition( | |
pbxVideo.ClientRectangle.Left, | |
pbxVideo.ClientRectangle.Top, | |
pbxVideo.ClientRectangle.Width, | |
pbxVideo.ClientRectangle.Height | |
); | |
} | |
catch | |
{ | |
// Gestión eventual de errores. | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment