简体   繁体   中英

Microsoft.DirectX.AudioVideoPlayback program not working

I'm trying to write a simple program that I'm going to be using inside another program for playing back audio and video files using the Microsoft.DirectX.AudioVideoPlayback.dll file. I've got the code listed below since it doesn't have to be incredibly complex. The problem that I am having is that... well, the program does nothing. Not even the main window shows up and I don't know why. I'm using .Net 4.0 and the DirectX DLL version says it's 1.0.2902.0. I tried moving the initialization for the audio and video files to different places (The load event and the button press event specifically). When in the button press event, the form loads, but as soon as I press a button, the program hangs. No errors or anything. Anyone know what is going on here? If someone has a better idea for playing audio and video files, I'm willing to consider that too.

using Microsoft.DirectX.AudioVideoPlayback;
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;

namespace MediaPlayer
{
    public partial class Player : Form
    {
        Audio derp;
        Video herp;        
        public Player()
        {
            InitializeComponent();
            this.derp = new Audio("<Audio File Name>");
            this.herp = new Video("<Video File Name>");
            this.herp.Owner = this.panel1;            
        }
        private void btnPlayPauseStop_Click(object sender, EventArgs e){            
            switch(((Button)sender).Text){
                case "Play":
                    if (!herp.Playing)
                        herp.Play();
                    break;
                case "Pause":
                    if (!herp.Paused)
                        herp.Pause();
                    break;
                case "Stop":
                    if (!herp.Stopped)
                        herp.Stop();
                    break;
            }
        }
        private void Player_Load(object sender, EventArgs e)
        {            

        }
    }
}

I have been using this for making my very own "Media Player Classic" clone

Be sure to debug this in 32 bit mode: Project Menu --> {project} Properties ... --> Build --> Platform Target = x86

For video, I do not load Audio (it gets done automatically). So instead of using both, use only the one needed (video or audio)

The next thing is to ensure that the panel is visible and big enough to see (check the size after "new Video(...)")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM