0

Windows Media Player で再生中の現在の曲のパスをユーザーに通知する小さなアプリケーションを作成しようとしています。

だから私は周りを検索して、良いコードに出くわしました:

WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer();
// Get an interface to the first media item in the library. 
WMPLib.IWMPMedia3 firstMedia = (WMPLib.IWMPMedia3)player.mediaCollection.getAll().get_Item(0);

// Make the retrieved media item the current media item.
player.currentMedia = firstMedia;

// Display the name of the current media item.
currentMediaLabel.Text = ("Found first media item. Name = " + player.currentMedia.name);

しかし問題は、このコードが実際には現在の曲を取得するのではなく、リストの最初の曲を取得することです。メソッドを変更しようとしましたが、うまくいきません:(そして、あなたが私を助けてくれることを願っています.

4

2 に答える 2

2

あなたはすでにそれを持っていplayer.currentMediaます。

WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer();

// start the player
...

if(player.currentMedia != null)
{
    // Display the name of the current media item.
    currentMediaLabel.Text = ("Found first media item. Name = "
                              + player.currentMedia.name);
}
于 2013-08-10T04:21:14.003 に答える