在WPF中使用Windows Media Player控件(visual basic)(vs2015) [英] Using windows media player control in WPF (visual basic)(vs2015)

查看:242
本文介绍了在WPF中使用Windows Media Player控件(visual basic)(vs2015)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在WPF中使用Windows Media Player控件



我尝试过:



在WPF项目中引用System.Windows.Forms添加。

添加到主窗体中以访问库:

xmlns:wf = clr-namespace:System.Windows.Forms; assembly = System.Windows.Forms

xmlns:ax =clr-namespace:AxWMPLib; assembly = AxInterop.WMPLib



我得到:

警告BC40056 Imports'AxWMPLib'中指定的命名空间或类型不包含任何公共成员或无法找到。确保定义了名称空间或类型,并且至少包含一个公共成员。确保导入的元素名称不使用任何别名。

另外:

严重性代码描述项目文件行抑制状态

错误未找到程序集AxInterop.WMPLib。验证您没有错过程序集引用。此外,验证是否已构建项目和所有引用的程序集。



代码:

< window x:class =MainWindowxmlns:x =#unknown>

xmlns =http://schemas.microsoft.com/winfx/2006/xaml/presentation

xmlns:x =http://schemas.microsoft.com/winfx/ 2006 / xaml

xmlns:d =http://schemas.microsoft.com/expression/blend/2008

xmlns:wf =clr-namespace: System.Windows.Forms; assembly = System.Windows.Forms

xmlns:ax =clr-namespace:AxWMPLib; assembly = AxInterop.WMPLib

xmlns:mc =http://schemas.openxmlformats.org/markup-compatibility/2006

xmlns:local =clr-namespace:WpfApplication1

mc:Ignorable = d

Title =MainWindowHeight =350Width =525>

< grid>




I am trying to use a Windows Media Player Control in WPF

What I have tried:

references in ther WPF project to System.Windows.Forms added.
added to main form to access libraries:
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:ax="clr-namespace:AxWMPLib;assembly=AxInterop.WMPLib"

I get :
Warning BC40056 Namespace or type specified in the Imports 'AxWMPLib' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
ALSO:
Severity Code Description Project File Line Suppression State
Error Assembly 'AxInterop.WMPLib' was not found. Verify that you are not missing an assembly reference. Also, verify that your project and all referenced assemblies have been built.

CODE:
<window x:class="MainWindow" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:ax="clr-namespace:AxWMPLib;assembly=AxInterop.WMPLib"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<grid>


推荐答案

为什么?看看这个类 System.Windows.Media.MediaPlayer ,它是WPF的一部分:

MediaPlayer类(System.Windows.Media) [ ^ ]。



我几乎无法想象直接使用AxWMPLib组件可以给你带来任何好处 System.Windows.Media .MediaPlayer 。首先尝试这个元素。如果你有任何理由认为它不够(哦,有很多这样的原因),你应该更好地诉诸一些其他组件,与臭名昭着的功能不佳的微软播放器无关。首先,它可能是基于VideoLAN(VLC)的组件。



-SA
Why? Look at this class System.Windows.Media.MediaPlayer, which is a part of WPF:
MediaPlayer Class (System.Windows.Media)[^].

I hardly can imagine that the use of the direct use of AxWMPLib component can ever give you any benefits over System.Windows.Media.MediaPlayer. Try this element first. If you have any reasons to consider it as insufficient (oh, there are a lot of such reasons), you should better resort to some other components, not related to notoriously feature-poor Microsoft player. First of all, it could be a component based on VideoLAN (VLC).

—SA


这篇关于在WPF中使用Windows Media Player控件(visual basic)(vs2015)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆