在WPF中将音乐文件注册到我的音乐播放器 [英] Register Music Files To My Music Player in WPF

查看:108
本文介绍了在WPF中将音乐文件注册到我的音乐播放器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WPF中创建了一个音乐播放器.

我创建了一个reg文件来将我的应用程序注册为默认应用程序,并在音乐文件上单击鼠标右键添加了我的应用程序名称"为打开".但是我仍然无法完成这项工作.当用户单击音乐文件时,我也想打开它的应用程序并在我的应用程序中播放音乐文件,我该怎么做?

编辑-我的意思是,当我单击音乐文件时,它会加载我的应用程序,但不会将音乐添加到我的应用程序列表中,并且不会播放.

我在接收文件时遇到了麻烦,我不知道该怎么做,我只是创建了一个可以选择播放内容的文件夹,然后选择音乐文件,然后播放音乐文件的url,或将文件拖放到我的应用程序中,我的应用播放列表,但是我不知道如何在使用音乐文件时单击音乐文件...

i created a Music Player in WPF.

i created a reg file to register my app as default , and added Open with "My App name" into right click on music files. but i still can`t get this work .also i want when user click on the music file , its open my app and play the music file in my app , how i can do that ?

Edit - i mean when i click on the music file it load my app , but not adding the music into my app list , and not playing it .

i have a trouble receiving the file, i don''t know how , i just created that you can select folder to play contents , and select music file , and play music file throw url , or drag files and drop them into my app or my app playlist , but i don`t know how to receive files when use click on the music file ...

推荐答案

对此进行了一些播放, Windows似乎通过将文件的路径作为参数传递给程序来以这种方式打开文件.您可以通过访问Program.Main的arguments数组在程序中获取参数,您可以在其中处理该参数,或者将其传递给表单的构造函数,然后由表单处理.
因此,在您的情况下,我建议将arguments传递给应用程序的主要形式,看看是否传递了任何参数,然后像通常打开程序中的文件一样打开它们.


忘了您使用的是WPF,它对命令行参数的处理略有不同,但是
Played around a bit with this, and it looks like Windows opens files that way by passing the file''s path to the program as an argument. You can get the arguments in your program by accessing the arguments array of Program.Main, where you can either deal with it there, or pass it to the constructor of your form, and let the form handle it.

So in your case, I would suggest probably passing arguments to the main form of your application, seeing if there are any arguments being passed in, and open them as you normally would open a file in your program.


Forgot you were using WPF, that handles command line arguments a little differently, but this[^] has an example of how to handle them in WPF apps.


除了lexwax00的正确答案:

您可以使用我的库来处理命令行参数.它特别易于使用,并在此CodeProject文章的源代码中提供:
基于枚举的命令行实用程序 [
In addition to the correct answer by lexwax00:

You can use my library to process command line arguments. It is especially easy to use and is provided in a source code for this CodeProject article:
Enumeration-based Command Line Utility[^].

—SA


这篇关于在WPF中将音乐文件注册到我的音乐播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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