[Implementation] Automatic loop playing MP3 player
[Application] Automatic loop playback MP3 player is mainly used for corporate culture. On the daily rest period, the player automatically loops to play the specified MP3 music. This automatic player is mainly written according to the company's situation, including morning to work, lunch, and in the afternoon, three time sections play for about 1 hour or so. After the player is started, only the icon in the tray, after configuring the music directory of each time period, does not require manual intervention, music can start, loop and end. It is now used in the company.
[Features] This software uses many common techniques:
1. ? Directory Selection dialog
2. • File Select Multiple File Type Filter Settings in Dialog
3. • The application is hidden on the taskbar and displays icons on the tray.
4. ? Production of progress bars
5. ? Timer use
6. • Button with link features - Click the button to open the electronic mailbox
7. ? Elliptical color button, color text
8. ? Color headline bar, color title text. and many more
[Principle] Mainly used timer. Once the program is run, the timer responds once a second. Until the procedure is manually exited.
[Main control]
M_MusicList --- ComboBox Type? Music File List
[Main procedures and descriptions]
Void cmp3playerdlg :: onOpen () // Click the Open button to select a music file. Multiple selection
{
?????? m_musiclist.resetcontent ();
?????? m_musicary.removell ();
?????? m_music.close (); ?? // m_music is a ccommci object
?????? init ();
?????? m_pause.setwindowText ("pause");
?????? //
?
?????? cstring filter = "Media file (all types) | * .cda; *. Mid; *. RMI; *. Midi; *. Asf; *. Wm; *. Wma; *. Asx; * . WAX; *. MPEG; *. mpg; *. M1V; *. mp3; *. Avi; *. wmv; *. WAV; *. SND; *. Au; *. AIF ; *. AIFC | "
?????? filter = filter "CD Music track (* .cda) | * .cda |"
??????????????????????????????????? "MIDI file (* .mid; *. RMI; *. MIDI) | * .MID; *. RMI; *. MIDI | "
??????????????????????????????????? "Windows Media file (* .ASF; *. Wm; *. WMA ; *. Wa?) | * .ASF; *. wm; *. wma; |
???????????????????????????????????? "media playlist (* .asx; *. Wax; *. M3u ; *. wvx) | * .asx; *. Wax; *. m3u; *. wvx |
??????????????????????????????????? "Movie file (* .mpeg; *. Mpg; *. M1V; * .mp3) | * .mpeg; *. mpg; *. m1v; *. mp3 |
????????????????????? ?????????????? "video file (* .avi; *. WMV) | * .avi ; *. WMV) | "
??????????????????????????????????? "Audio file (* .wav; *. SND; *. AU; * .AIF; *. AIFC) | * .wav; *. SND; *. Au; *. AIF; *. AIFC |
??????????????????????????????????? "all files (*. *) | *. * |
?????? cfiledialog music (True, null, null, OFN_HIDEREADOONLY | OFN_ALLOWMULTITILECT, FILTER);
?????? if (music.domodal () == iDok)
?????? {
?????? ?????? Position POS = Music.getStartPosition ();
?????? ?????? while (POS! = null)
????????????? {
??????????????????? cstring str = music.getnextpathname (POS);
?????????????? ?????? m_musicary.add (STR);
???????????????????? INDEX = str.reversefind ('// ");
??????????????????? f (index == -1)
?????????????????????????? M_MusicList.AddString (STR);
??????????????????? ELSE
????????????? ?????? {
????????????????????? ?????? cstring name = str.mid (INDEX 1);
??????????????????????????? M_MusicList.AddString (name);
????????????? ??????}
?????????????}
??????}
}
============================
Void cmp3playerdlg :: Play (int index) // Play function, index is the number of tracks
{
?????? m_music.close ();
?????? m_musiclist.setcursel (index);
?????? cstring spath = m_musicary.getat (index);
?????? m_music.open (SPATH);
?????? m_status.setwindowtext (Spath _t ("Play ...")); // Display prompt information in the status bar
?????? m_nlength = m_music.getLength (); // Get music length
?????? m_npos = 0;
?????? m_ntime = m_nlength / 1000; // divided by 1000 to play time
?????? //
?????? m_smusiclen.format ("% D minutes% D seconds", m_ntime / 60, m_ntime% 60); // Display play time
?????? m_smusicpos.format ("% D minutes% D seconds", m_npos / 60, m_npos% 60); // Display the current play position
?????? //
?????? Updatedata (false);
?????? m_mpbar.setscrollRange (0, m_ntime); // Set the schedule range of music playback
?????? // ?????? m_volume.setRange (0,1000); // Set the volume adjustment range
?????? m_volume.setpos (m_nvolume);
?????? //
?????? m_music.play (this-> m_hwnd); // Start playback
?????? setTimer (2, 1000, null); // Start 2 Timer
}
============================