c# - C# 媒体播放器(VLC 或 WMP)不播放
问题描述
我正在尝试构建一个简单的媒体播放器。它只有浏览按钮、播放按钮和媒体播放器屏幕。我尝试使用 Windows Media Player 和 VLC Media Player。在下面的两个代码中,Button1
用于浏览视频。Button2
是用来玩的。浏览工作正常,但如果我单击 Button2,则没有任何反应,并且我尝试查看消息是否存在,但它不会catch
。
如果我使用 Windows Media Player,我使用此代码;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace videoplayerdeneme
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
OpenFileDialog opf = new OpenFileDialog();
if (opf.ShowDialog() == DialogResult.OK)
{
//textBox1.Text = opf.FileName;
axWindowsMediaPlayer1.URL = opf.FileName;
}
}
private void Button2_Click(object sender, EventArgs e)
{
try {
axWindowsMediaPlayer1.Ctlcontrols.play();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
当我想使用 VLC 媒体播放器时,我使用此代码;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace videoplayerdeneme
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
OpenFileDialog opf = new OpenFileDialog();
if (opf.ShowDialog() == DialogResult.OK)
{
//textBox1.Text = opf.FileName;
axVLCPlugin21.playlist.add(opf.FileName, opf.SafeFileName, null);
}
}
private void Button2_Click(object sender, EventArgs e)
{
try {
axVLCPlugin21.playlist.play();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
在这两种情况下我都缺少什么?请帮我。
编辑 我没有将 64 位 VLC 媒体播放器添加到工具箱,所以我安装了 32 位版本,即使我的电脑有 64 位
解决方案
推荐阅读
- java - 没有 JRE 的新 JDK 12?这是如何运作的?
- c# - 为什么反序列化的 JSON 数组返回 null?
- javascript - 跨 DIN A4 页面拆分文本
- javascript - 反应中的电子邮件编码和基本身份验证
- php - Laravel 路由注册在提交时看不到注册(RegisterRequest $request)
- excel - 从excel转换为文本文件时如何删除双引号?
- php - 避免按天添加日期循环?
- javascript - RequestAnimationFrame 定期加速/减速
- postgresql - 在 postgres 中收到重复声明错误
- r - 如何在内部启用 Shiny(通过 LAN)托管 R Markdown 文档