如何将多个文件添加到播放列表

编程入门 行业动态 更新时间:2024-10-20 21:01:01
本文介绍了如何将多个文件添加到播放列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有了多选= TRUE 有一个打开文件对话框控制。现在,我想添加的每个文件到Windows Media Player播放列表,但我不知道该怎么做,并没有在互联网上没有很好的例子。

如果(ofdSong.ShowDialog()== DialogResult.OK) {的foreach(在ofdSong.FileNames字符串文件) { //代码中加入文件到播放列表} }

解决方案

使用 DJ KRAZE 的帮助,给了我这个例子链接,的JayJay 谁写的例子,这里是解决方案。

WMPLib.IWMPPlaylist播放列表= wmp.playlistCollection.newPlaylist(myplaylist); WMPLib.IWMPMedia媒体; 如果(ofdSong.ShowDialog()== DialogResult.OK) {的foreach(在ofdSong.FileNames字符串文件) { =媒体wmp.newMedia(文件); playlist.appendItem(媒体); } } wmp.currentPlaylist =播放列表; wmp.Ctlcontrols.play();

I have one OpenFileDialog control that has Multiselect = true. Now I want to add each file to windows media player playlist but I have no idea how to do that and there is no good example on the internet.

if (ofdSong.ShowDialog() == DialogResult.OK) { foreach (string file in ofdSong.FileNames) { //Code to add file to the playlist } }

解决方案

With help of DJ KRAZE that gave me the example link and JayJay who wrote that example, here is the solution.

WMPLib.IWMPPlaylist playlist = wmp.playlistCollection.newPlaylist("myplaylist"); WMPLib.IWMPMedia media; if (ofdSong.ShowDialog() == DialogResult.OK) { foreach (string file in ofdSong.FileNames) { media = wmp.newMedia(file); playlist.appendItem(media); } } wmp.currentPlaylist = playlist; wmp.Ctlcontrols.play();

更多推荐

如何将多个文件添加到播放列表

本文发布于:2023-11-23 15:58:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622043.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   播放列表   如何将   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!