home *** CD-ROM | disk | FTP | other *** search
- //////////////////////////////////////////////////////////////////////////////
- // CDRPlay.cpp
- //
- // ©1995,96 SynthoWare
- // Simple CD Audio Player that doesn't display track/disk time
- //
- // Programmed By: Deryk B Robosson
- // E-mail: newlook@free.org
- // nur_hutsko@online.emich.edu
- // Snail-mail: 32609 Manistee
- // Westland, MI 48186
- // +1.313.990.3599
- // IRC: Channel #amiga as newlook
- //
- // Used: * AFrame
- // - Amiga C++ OOP Programmers Enhancements
- // - By Jeffry A Worth
- // - e-Mail: worth@online.emich.edu
- // 73410.1112@compuserve.com
- // - And Deryk B Robosson
- // - See above for bug reports etc.
- //
- // * CygnusEd Professional v3.6
- // - From CygnusSoft Software
- // - Copyright © 1987-1993 CygnusSoft Software
- //
- //////////////////////////////////////////////////////////////////////////////
-
- //////////////////////////////////////////////////////////////////////////////
- // Includes
- #include "aframe:cdrplay/cdrplay.hpp"
-
- ///////////////////////////////////////////////////////////////////////////////
- // About Window Class Definition
- // We have to tell the user about us a little bit don't we? ;)
-
- class AboutWindow: public AFWindow
- {
- public:
-
- virtual void OnCreate();
- virtual void OnGadgetUp(LPIntuiMessage imess);
- virtual void OnCloseWindow(LPIntuiMessage imess);
- virtual void DestroyWindow();
-
- AFPanel AboutPanel; // One panel for button
- AFPanel info_panel; // One panel for Info
- AFImageButton AboutButton; // One button!
- };
-
- //////////////////////////////////////////////////////////////////////////////
- // ControlWindow Class Definition
- // Main window definitions for our primary input
-
- class ControlWindow: public AFWindow
- {
- public:
- virtual void OnCreate();
- virtual void OnGadgetUp(LPIntuiMessage imess);
- virtual void OnCloseWindow(LPIntuiMessage imess);
- virtual ULONG WindowFlags();
-
- AFCD_Rom cd;
- AFImageButton Next, Prev, Stop, Play, Pause, About; // Our many image buttons
- };
-
- //////////////////////////////////////////////////////////////////////////////
- // ControlWindow Implementation routines
-
- // What we do on an exit request from the user
-
- void ControlWindow::OnCloseWindow(LPIntuiMessage imess)
- {
- AFWindow::DestroyWindow();
- }
-
- // We override the OnCreate() function so we can do some extra things that it
- // doesn't do for us.
- void ControlWindow::OnCreate()
- {
- cd.CDCreate((UBYTE*)"scsi.device",(ULONG)2);
- cd.SCSI_ReadTOC();
- mytrack=1;
- }
- // We override the OnGadgetUP function so we can handle the messages accordingly
- void ControlWindow::OnGadgetUp(LPIntuiMessage imess)
- {
- AFRastPort rp(this);
- AFRect rect, aboutrect;
- AboutWindow *about;
-
- switch(((struct Gadget*)imess->IAddress)->GadgetID) {
- case ID_PLAY: // User pressed PLAY button
- cd.SCSI_CDPlay((ULONG)2,(ULONG)3); // play from mytrack to end of disc
- printf("Track: %ld\n",mytrack);
- break;
-
- case ID_PAUSE: // User pressed PAUSE Button
- cd.SCSI_CDPause(); // Pause the disc
- break;
-
- case ID_STOP: // User pressed STOP button
- cd.SCSI_CDStop(); // Stop the disc
- break;
-
- case ID_NEXT: // User pressed NEXT track button
- mytrack+=1;
- if(mytrack > cd.cd_toc.cdc_NumTracks) // make sure we can advance track
- mytrack=cd.cd_toc.cdc_NumTracks; // if not, set mytrack to last track
-
- cd.SCSI_CDPlay(mytrack,(ULONG)NULL); // play next track
- printf("Track: %ld\n",mytrack);
- break;
-
- case ID_PREV: // User Pressed PREV track button
- mytrack-=1;
- if(mytrack==0) // make sure we can decreace track
- mytrack=1; // if not, set mytrack to first track
-
- cd.SCSI_CDPlay(mytrack,(ULONG)NULL); // play previous track
- printf("Track: %ld\n",mytrack);
- break;
-
- case ID_ABOUT: //User wants to know about us yeah, yeah, yeah!
- aboutrect.SetRect(10,10,212,115);
- about=new AboutWindow;
- about->Create(m_papp,&aboutrect); // Create our new window and wait...
- break;
-
- default:
- AFWindow::OnGadgetUp(imess); // the message wasn't for us, return it to Intuition
- break;
- }
- }
-
- ULONG ControlWindow::WindowFlags() // Added WindowFlags
- {
- return (AFWindow::WindowFlags() | WFLG_GIMMEZEROZERO);
- }
-
- //////////////////////////////////////////////////////////////////////////////
- // About Window Implementation routines
- //
- // Deryk Robosson
- // December 18,1995
- //
-
- void AboutWindow::OnCreate() // What we are doing when our AboutWindow
- { // is being Created
- AFRect rect;
-
- rect.SetRect(2,11,94,103); // Set up our panel because image buttons can't have
- // Borders on them...
- AboutPanel.Create("",this,&rect,ID_ABOUTPANEL,PANEL_BEVELUP);
-
- rect.SetRect(4,13,92,101); // Set up the main image button
- AboutButton.Create(this,&rect,ID_ABOUTBOX,&about_image,NULL);
-
- rect.SetRect(96,11,184,103); // Create a panel for our useless text to be place in
- info_panel.Create("General Info",this,&rect,ID_ABOUTPANEL,PANEL_BEVELUP);
-
- AFWindow::RefreshGadgets(); // Refresh the glist so we can see what we did! :)
- }
-
- void AboutWindow::OnGadgetUp(LPIntuiMessage imess)
- {
- switch(((struct Gadget*)imess->IAddress)->GadgetID) {
-
- case ID_ABOUTPANEL: // Handle things when user presses any of the three buttons
- case ID_ABOUTBOX:
- AboutWindow::DestroyWindow();
- break;
- default:
- AFWindow::OnGadgetUp(imess); // Wasn't our message!? :/
- break;
- }
- }
-
- void AboutWindow::OnCloseWindow(LPIntuiMessage imess) // time to leave!! ;)
- {
- AboutWindow::DestroyWindow();
- }
-
- void AboutWindow::DestroyWindow() // let's get rid of our about window
- {
- AFWindow::DestroyWindow();
- delete this;
- }
-
- //////////////////////////////////////////////////////////////////////////////
- // MAIN
-
- void main()
- {
- AFAmigaApp theApp;
- AFRect rect(10,10,178,60); // Size of our main window
- ControlWindow win;
-
- win.Create(&theApp,&rect,"CDPlay"); // Create our main window
-
- rect.SetRect(2,2,24,35); // Create Previous button
- win.Prev.Create(&win,&rect,ID_PREV,&prev_render_image,&prev_select_image);
-
- rect.SetRect(26,2,48,35); // Create Next button
- win.Next.Create(&win,&rect,ID_NEXT,&next_render_image,&next_select_image);
-
- rect.SetRect(50,2,72,35); // Create Stop button
- win.Stop.Create(&win,&rect,ID_STOP,&stop_render_image,&stop_select_image);
-
- rect.SetRect(74,2,96,35); // Create Play button
- win.Play.Create(&win,&rect,ID_PLAY,&play_render_image,&play_select_image);
-
- rect.SetRect(98,2,120,35); // Create Pause button
- win.Pause.Create(&win,&rect,ID_PAUSE,&pause_render_image,&pause_select_image);
-
- rect.SetRect(122,2,144,35); // Create About button
- win.About.Create(&win,&rect,ID_ABOUT,&about_render_image,&about_select_image);
-
- win.RefreshGadgets(); // Let's refresh so you can see our work!
-
- theApp.RunApp(); // run the app and forget about it, it'll
- // take care of itself! ;) (isn't C++ wonderful??)
- }
-