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);
Time functions: The
Open function is in 'Player.cs' is used to open media files to play with the MCI command strings.
komut = "status Sarki length";
mciSendString(komut, donendeger, donendeger.Capacity, IntPtr.Zero);
Button press events:
trcsarkiyer2 is a scrollbar to follow the media status and SarkiUzunlukMilisaniye is a 'status media file' function.
trcsarkiyer2.Maximum = SarkiUzunlukMiliSaniye(sira);
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 ;)