Click here to Skip to main content
13,597,188 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


16 bookmarked
Posted 15 Feb 2011
Licenced CPOL

Media Player With MCI

, 15 Feb 2011
Rate this:
Please Sign up or sign in to vote.
A media player with winmm.DLL (MCI). Includes radio, search playlist, nd line up playlist (optional) features.


This article is about MCISENDSTRING and winmm.dll. I use them to play media files and this is a good sample about playing media files. I know you can find a lot of examples about MCI but not like this one. This sample project has a radio selection and you can edit it however you desire by adding radio URLs. I will improve its interface and will handle its bugs as and when I get time.

To find songs, use 'CTRL+F'. You can sort your playlist with 'CTRL+S' and play your order with 'S' or clean up your order with 'SHIFT+S'. In the 'Görsel Öğe' tab you can see the MP3 tags, media file length (-/+), your playlist's length (in minutes), and you can specify your interface by selecting the background and foreground colours. In the 'Seçenekler' tab, and you can choose how you want to listen to songs (random, repeat single song, repeat playlist, loop (at the end of the playlist)). And in this tab, you can save your list and in one click, you can get it all the time (see the listbox on the right). And of course, the radio section, I want you to explore it. :)

This solution helps you to learn MCISENDSTRING commands, and you should look at 'Player.cs'. Also, you can look in the 'Registry' region to learn the Regedit entries using C#, the 'Zaman' region to learn about MCI time commands like 'status media length', the 'MP3 ID3v1' region to learn about an MP3's ID3v1 information like 'Artist', 'Year', and the other regions to examine other functions in 'Player.cs'.

You can use any of my code parts in your projects. It will help you to learn about MCI , because almost all of code parts have explanations.

Using the code

Firs of all, we need the Player class to play media files because it has MCI commands in functions. The content is explained at the top. In the Mp3PLayer (Main Form) constructor, there are some similarities because almost all of the component functions are in Player.cs. The main similarity is Player muzik=new Player();. This is important. In the 'DragDrop' region, you can learn about drag drop (Desktop to WinForms, directory to WinForms, file to WinForms). Also, for interface changes like colour changes, look in the 'Skins' region.

Global variables and importing winmm.DLL:

private static extern long mciSendString(string strKomut, 
        StringBuilder strDonenDeger, int mediaUzunluk, IntPtr hwndCallback);
//And I Used it in Functions
//It is a classic API using.

Time functions: The Open function is in 'Player.cs' is used to open media files to play with the MCI command strings.

SarkiUzunlukMiliSaniye(int sira)

komut = "status Sarki length";
mciSendString(komut, donendeger, donendeger.Capacity, IntPtr.Zero); //Media File LENGTH!
return Convert.ToInt32(donendeger.ToString());

Button press events: trcsarkiyer2 is a scrollbar to follow the media status and SarkiUzunlukMilisaniye is a 'status media file' function.

Play(int sira)

Open(lst.Items[sira].SubItems[1].Text); //Other Function Of MCI
trcsarkiyer2.Maximum = SarkiUzunlukMiliSaniye(sira); //ScrollBar For Position And Length
komut = "play Sarki";
mciSendString(komut, null, 0, IntPtr.Zero);
play = true;


This is my first article. This app might contain bugs. It is only intended as a learning tool. Happy coding ;)


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Team Leader
Turkey Turkey
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
FernandoUY20-Jun-12 5:25
memberFernandoUY20-Jun-12 5:25 
GeneralRe: My vote of 1 Pin
SercanOzdemir20-Jun-12 9:53
memberSercanOzdemir20-Jun-12 9:53 
Questionmy vote of 4 Pin
Member 392526414-Feb-12 3:07
memberMember 392526414-Feb-12 3:07 
AnswerRe: my vote of 4 Pin
SercanOzdemir14-Feb-12 21:03
memberSercanOzdemir14-Feb-12 21:03 
GeneralMy vote of 5 Pin
Member 78700106-May-11 6:51
memberMember 78700106-May-11 6:51 
GeneralMy vote of 3 Pin
TV Mogul15-Feb-11 4:21
memberTV Mogul15-Feb-11 4:21 
GeneralRe: My vote of 3 Pin
SercanOzdemir3-Mar-11 1:40
memberSercanOzdemir3-Mar-11 1:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.180621.3 | Last Updated 15 Feb 2011
Article Copyright 2011 by SercanOzdemir
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid