![](/img/trans.png)
[英]Microsoft.DirectX.AudioVideoPlayback alternative in SharpDX
[英]Microsoft.DirectX.AudioVideoPlayback program not working
我正在嘗試編寫一個簡單的程序,該程序將在另一個程序中使用Microsoft.DirectX.AudioVideoPlayback.dll文件播放音頻和視頻文件。 我已經在下面列出了代碼,因為它不必非常復雜。 我遇到的問題是……很好,該程序什么也不做。 甚至主窗口都沒有出現,我也不知道為什么。 我使用的是.Net 4.0,DirectX DLL版本說它是1.0.2902.0。 我嘗試將音頻和視頻文件的初始化移動到不同的位置(特別是load事件和按鈕按下事件)。 在按鈕按下事件中,將加載表單,但是一旦我按下按鈕,程序就會掛起。 沒有錯誤或任何東西。 有人知道這是怎么回事嗎? 如果有人對播放音頻和視頻文件有更好的主意,我也願意考慮。
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)
{
}
}
}
我一直在用它制作我自己的“ Media Player Classic”克隆
確保以32位模式進行調試:項目菜單-> {project}屬性...->構建->平台目標= x86
對於視頻,我不加載音頻(它會自動完成)。 因此,不要同時使用兩者,而只使用所需的一種(視頻或音頻)
接下來是確保面板可見且足夠大以查看(檢查“ new Video(...)”之后的大小)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.