friendsterTalk - Friendster Forum

friendsterTalk - Friendster Forum

Welcome guest! Please Login or Register.

#1  2008-11-11 17:20:38

creamownedz
 active server protocol
creamownedz's display avatar
» FriendsterTalker
PsychoCoder
Class-S
Location: Ftalk & MCTF
Registered: 2008-03-22
Posts: 115
Last visit: Yesterday
Reputation: 7

Retrieve songs on a CD in C# [c#]

This is a snippet to retrieve a list of songs from a music CD in the CDROM Drive. This is used in conjunction with the AxWindowsMediaPlayer (wmp.dll). This snippet uses the IWMPPlaylist Interface to gain access to the playlist on the CD



Instructions:
First, you need a reference to wmp.dll:
1. Click Projects > Add Reference
2. Click the COM tab
2. Scroll down and select Windows Media Player (wmp.dll)

Next you need a reference to AxWMPLib
The pass your player object to the method, and it will return a string array of the songs on the CD


Code:

//Namespace reference
using AxWMPLib;

/// <summary>
/// method to retrieve the songs from a music CD
/// </summary>
/// <param name="player">the WMP object that will be playing the songs</param>
/// <returns>string array or track names</returns>
public string[] GetTracksFromCD(AxWindowsMediaPlayer player)
{
    // use the IWMPPlaylist Interface, which will give us
    //access to the songs on the CD
    WMPLib.IWMPPlaylist songs = player.cdromCollection.Item(0).Playlist;

    // string array to hold the songs on the CD
    String[] songList = new String[songs.count];

    // loop through the songs on the CD
    for (int i = 0; i < songs.count; i++)
    {
        //add each song to our string array using
        //the get_Item Method of the AxWindowsMediaPlayer
        songList[i] = songs.get_Item(i).name;
    }

   //return the songs
    return songList;
}

...Giving of reputation are highly appreciating for me...
Computers don't make errors what they do they do on purpose
...computer is my expertise...
....an addicted coder....
....don't ripp all my tutorials....

Search Friendstertalk

Board footer

FriendsterTalk is not affiliated with Friendster.com
Copyright © 2002–2009 PunBB

[ 8 queries - 0.025 second ]

Pay Per Click Ads by pay per click advertising by Kontera

FriendsterTalk.com x

Welcome to FriendsterTalk! You'll need to login in order to fully use all the features and view all the sections of this site.

Please register if you're not yet a member. =)