/*************************************************************************************************/ /* Fichiers d'en-tête nécessaires*/ /*********************************/ #include "cd_audio.h" /*************************************************************************************************/ /* Code Source de la classe prog_win */ /**************************************/ cd_audio::cd_audio(HWND hwnd) { bpause = false; bplaying = false; handle = hwnd; } /*************************************************************************************************/ cd_audio::~cd_audio() { launch_mci_command("stop cdaudio"); launch_mci_command("eject cdaudio"); launch_mci_command("close cdaudio"); } /*************************************************************************************************/ void cd_audio::play_track(int no_track) { char command[100]; begin_time_for_track(no_track); sprintf(command,"play cdaudio from %s",begin_time_for_track(no_track)); launch_mci_command(command); bplaying = true; } /*************************************************************************************************/ void cd_audio::play_track(char *beg_time,char *end_time) { char command[100]; sprintf(command,"play cdaudio from %s to %s",beg_time,end_time); launch_mci_command(command); bplaying = true; } /*************************************************************************************************/ void cd_audio::pause() { static char time[50]; char command[100]; if (bpause) { sprintf(command,"play cdaudio from %s",time); launch_mci_command(command); bpause = false; } else { strcpy(time,cd_elapsed_time()); launch_mci_command("pause cdaudio"); bpause = true; } } /*************************************************************************************************/ BOOL cd_audio::is_playing() { return (bplaying); } /*************************************************************************************************/ BOOL cd_audio::is_pause() { return (bpause); } /*************************************************************************************************/ void cd_audio::stop() { launch_mci_command("stop cdaudio"); bplaying = false; } /*************************************************************************************************/ char *cd_audio::cd_length() { launch_mci_command("status cdaudio length"); return (ret_mci_str); } /*************************************************************************************************/ char *cd_audio::cd_elapsed_time() { launch_mci_command("status cdaudio position"); return (ret_mci_str); } /*************************************************************************************************/ char *cd_audio::track_length(int no_track) { char str[100]; sprintf(str,"status cdaudio length track %d",no_track); launch_mci_command(str); return (ret_mci_str); } /*************************************************************************************************/ char *cd_audio::begin_time_for_track(int no_track) { char str[100]; sprintf(str,"status cdaudio position track %d",no_track); launch_mci_command(str); return (ret_mci_str); } /*************************************************************************************************/ int cd_audio::nb_track() { launch_mci_command("status cdaudio number of tracks"); return (atoi(ret_mci_str)); } /*************************************************************************************************/ void cd_audio::launch_mci_command(char *command) { static DWORD ret_len = sizeof(ret_mci_str) / sizeof(TCHAR); mciSendString(command, ret_mci_str,ret_len,handle); } /*************************************************************************************************/ /* Fin du fichier Source */ /*************************/