如何将多个文件添加到播放列表 [英] How to add multiple files to a playlist

查看:317
本文介绍了如何将多个文件添加到播放列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有了多选= 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();

这篇关于如何将多个文件添加到播放列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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