Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement