Automatic loop playing MP3 player (continued)

zhaozj2021-02-16  70

BOOL CMP3PLAYERDLG :: OnInitDialog () // Initialization Function

{

?????? m_dlgStyle.stitleName = "Music Player"; // Setting the title

?????? cownerdrawdialog :: onInitdialog ();

?

?????? // set the icon for this dialog.? The framework does this Automatically

?????? //? When the application's main window is not a dialog

?????? seticon (m_hicon, true); ???????????????? // set Big icon

?????? seticon (m_hicon, false); ?????? // set small icon

?????? settimer (4, 100, null); // Start 4 Timer

///

?????? ing (m_bautorun)

?????? ?????? settimer (1, 1000, null); // If it is automatic playback, start the No. 1 schema

?????? // The following is the app concealed the taskbar, put the program went in the tray.

?????? long wl = getWindowlong (this-> getsafehwnd (), gwl_exstyle;

?????? setWindowlong (this-> getsafehwnd (), gwl_exstyle, ws_ex_toolwindow;

?????? //

?????? notifyicondata tnd;

?????? tnd.cbsize = sizeof (notifyicondata);

?????? tnd.hwnd = this-> m_hwnd;

?????? tnd.uid = IDI_MAINFRAME;

?????? tnd.uflags = nif_message | NIF_ICON | NIF_TIP;

?????? tnd.ucallbackMessage = WM_DLG_SHOW;

?????? tnd.hicon = loading (), makeintresource (idi_maInframe);

?????? Strcpy (tnd.sztip, "music player");

?????? shell_notifyicon (NIM_ADD, & TND);

?

?????? Return True ;? // RETURN TRUE? UnsS you set the focus to a control

}

=====================================

Void cmp3playerdlg :: onhscroll (uint nsbcode, uint npos, cscrollbar * pscrollbar) // Drag music play progress bar

{

?????? f (pscrollbar == & m_mpbar)

?????? {

?????? ?????? switch (nsbcode)

????????????? {

????????????? case sb_thumbtrack:

?

????????????? ?????? m_npos = npos;

????????????? ?????? Break;

?????????????}

?????? ?????? m_mpbar.setscrollpos (m_npos); // change progress bar position

?????? ?????? m_music.seek (m_npos * 1000); // change the progress of music playback

?????? ?????? ing (m_bpause)

????????????? {

??????????????????? m_bpause = false;

????????????? ?????? m_pause.setWindowText ("pause");

?????????????}

?????? ?????? m_music.play (this-> m_hwnd);

??????}

??????

?????? cownerdrawdialog :: onhscroll (nsbcode, npos, pscrollbar);

}

=====================================

LResult Cmp3Playerdlg :: OndlgShow (WPARAM WPARAM, LPARAM LPARAM) // System Tray Click the icon response function

{

?????? uint UID; / / Issue ID of the icon for this message

?????? uint umousemsg; // mouse action

?????? Point pt;

?????? uid = (uint) wPARAM;

?????? umousemsg = (uint) LPARAM;

?????? getCursorpos (& PT);

?

?????? ife (uid == idi_mainframe)

?????? {

?????? ?????? f (umousemsg == wm_lbuttondown) // If you are click the left button, pop up the window

????????????? {

???????????????????? ing (! isiconic ())

????????????????????? ?????? {

????????????????????????????????? showwindow (sw_normal);

??????????????????????????? ?????? Return True

????????????????????? ??????}

???????????????????? showWindow (sw_normal);

?????????????}

?????????????? Else if (umousemsg == WM_RBUTTONDOWN) / / Click the right button to pop up the right mumgus

????????????? {

?????????????? ?????? cmenu Menu

????????????? ?????? Menu.LoadMenu (IDR_MENU);

?????????????? ?????? cmenu * popmenu = menu.getsubmenu (0);

?????????????? ?????? popmenu-> TRACKPOPUPMENU (TPM_LEFTBUTTON, PT.X, PT.Y, this); ????????????? }

?

??????}

?????? returnit;

}

==========================================================================================================================================================

Void cmp3playerdlg :: ONTID NIDEVENT / / Timer Processing

{

?????? if (nidevent == 1) // 1 timer, mainly processing automatic playback

?????? {

????????????? //

?????? ?????? init ();

?????? ?????? ing (! m_bautorun)

????????????? {

????????????? ?????? Return

?????????????}

?????? ?????? if (! m_cfile.open ()) // If there is an automatic play setting, automatic playback

????????????? {

????????????? ?????? Return

?????????????}

????????????? //

?????? ?????? m_cfile.readsetInfo (m_setinfo);

?????? ?????? systemTIME SYSTIME;

?????? ????? getlocaltime (& system);

?????? ?????? m_cfile.readdayInfo (Systime.wdayofweek, m_info);

?????? ?????? m_cfile.close ();

????????????? INT Hour = gethour (m_info.ssstarttime);

????????????? Int minute = getminute (m_info.ssstarttime);

?????? ?????? f (systime.wHour == Hour && system.wminute == minute) // Start playing morning music

????????????? {

????????????? ??????? ?????? READCATALOGMUSIC (M_INFO.SSMUSIC); / / read the morning playing music directory specified in the configuration file

????????????? ?????? m_nplay = 0;

??????????????????? play (0);

?????????????? ?????? killtimer (1); // terminate the No. 1 timer

??????????????????? INT DURATION = ATOI (m_info.ssduration); // read the playback time period

????????????? ?????? setTimer (3, DURATION * 60 * 1000, null); // Start the 3 Timer

????????????? ?????? m_nflag = 1;

????????????? ?????? Return

?????????????}

????????????? Hour = gethou (m_info.smstarttime);

?????? ?????? minute = getminute (m_info.smstarttime); ?????? ?????? ife (systime.wHour == Hour && systemime.wminute == minute) / / Start playing noon music

????????????? {

??????????????????? readcatalogmusic (m_info.smmusic);

????????????? ?????? m_nplay = 0;

??????????????????? play (0);

?????????????? ?????? killtimer (1);

??????????????????? Int duration = ATOI (m_info.smduration);

???????????????????? setTimer (3, Duration * 60 * 1000, NULL);

???????????????????? m_nflag = 2;

????????????? ?????? Return

?????????????}

????????????? Hour = gethour (m_info.sestarttime);

?????? ?????? minute = getminute (m_info.sestarttime);

?????? ?????? IF (systime.wHour == Hour && system.wminute == minute) / / start playing the afternoon music

????????????? {

?????????????? ????? ie readcatalogMusic (m_info.semusic);

????????????? ?????? m_nplay = 0;

??????????????????? play (0);

?????????????? ?????? killtimer (1);

?????????????? ?????? int duration = ATOI (M_INFO.SEDURATION);

???????????????????? setTimer (3, Duration * 60 * 1000, NULL);

????????????? ?????? m_nflag = 3;

????????????? ?????? Return

?????????????}

// ???? ?????? setTimer (1, 1000, null);

?????? ?????? m_cfile.close ();

??????}

?????? if (nidevent == 3) // 3 timer, is the play time period timer, the play time is here, automatically stop playing, start the No. 1 timer, waiting for the beginning of the next play, at the same time Turn off the 2nd and 3 timers and terminate play.

?????? {

?????? ?????? IF (m_music.isopen ())

????????????? {

????????????? ?????? m_music.close ();

??????????????????? settimer (1, 1000, null);

????????????? ?????? killtimer (2);

????????????? ?????? killtimer (3);

?????????????}

?????? ?????? Return;

??????}

?????? if (nidevent == 4) // 4 timer is to hide the window immediately. Can also be treated with MoveWindow

?????? {

?????? ?????? showwindow (sw_hide); ?????? ?????? killtimer (4);

?????? ?????? Return;

??????}

?????? f (nidevent == 2 && m_music.isopen () &&! m_bpause) // 2 Timer is in order to modify the status of each control in the dialog box, such as playing progress bar, current play time, etc.

?????? {

?????? ?????? m_npos = 1;

?????? ?????? m_smusicpos.format ("% D minutes% D seconds", m_npos / 60, m_npos% 60);

?????? ?????? Updatedata (false);

?????? ?????? m_mpbar.setscrollpos (m_npos);

?????? ?????? IF (m_npos> = m_ntime)

????????????? {

????????????? ?????? IF (m_nplay == m_musicary.getsize () - 1)

????????????? ?????? {

??????????????????????????? IF ((m_bautorun && m_setinfo.bcyc) ||! m_bautorun)

????????????????????? ?????? {

????????????????????????????????? m_nplay = 0;

???????????????????????????????? Play (0);

??????????????????????????? ?????? m_mpbar.setscrollpos (0);

????????????????????? ??????}

?????????????????????????? ELSE

????????????????????? ?????? {

????????????????????? ????????????? // entered sleep

????????????????????????????????? M_Music.Close ();

????????????????????????????????? settimer (1, 1000, null);

??????????????????????????? ?????? killtimer (2);

????????????????????????????????? killtimer (3);

???????????????????????????????? Return

????????????????????? ??????}

????????????? ??????}

??????????????????? ELSE

????????????? ?????? {

????????????????????? ?????? PLAY ( m_nplay);

????????????????????? ??????? m_mpbar.setscrollpos (0);

????????????? ??????}

?????????????}

??????}

?????? cownerdrawdialog :: ONTIMER (Nidevent);

}

[Remarks]: Due to many auxiliary modules for this software, this is not described here. If you are interested in friends, you can leave Email, and the author can send the program for free.

Player legend

转载请注明原文地址:https://www.9cbs.com/read-22419.html

New Post(0)