home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Aktief 1995 #3 / CDA3.iso / clipper / fs35cd.zip / CDPLAY.PRG < prev    next >
Text File  |  1995-01-11  |  4KB  |  128 lines

  1. #include "inkey.ch"
  2.  
  3. #define CD_PLAYING 768
  4.  
  5. FUNCTION cdDemo()
  6. LOCAL nKey     := 0
  7. LOCAL nJamp    := 1
  8. LOCAL aSongs
  9. LOCAL nSong
  10. LOCAL nCursor  := SetCursor( 0 )
  11. LOCAL aExit
  12. LOCAL aPlay
  13. LOCAL aStop
  14. LOCAL aResume
  15. LOCAL aEject
  16. LOCAL cScreen
  17. LOCAL nY       := Row()
  18. LOCAL cMain    := SaveScreen( 0, 0, 24, 79 )
  19. LOCAL nVolumeL := sbCDVolL()
  20. LOCAL nVolumeR := sbCDVolR()
  21. LOCAL lChannel := .T.
  22.     IF ! cdinstall()
  23.       ? "Sorry, CRROM driver not loaded"
  24.     ELSE
  25.       SetColor( "W/B, W+/B" )
  26.       BoxOpen(  9,  9, 19, 70, "b" )
  27.       BoxOpen( 10, 10, 13, 69, "b" )
  28.       @ 11, 12 SAY "CD-ROM Audio Player created with FAST.lib by Manu Roibal" COLOR "gr+/b"
  29.       @ 14, 13 SAY replicate( "■", 10 ) COLOR "g+/b"
  30.       @ 15, 13 SAY replicate( "■", 10 ) COLOR "g+/b"
  31.       @ 14, 30 SAY "Left Channel "      COLOR "b+/b"
  32.       @ 15, 30 SAY "Right Channel"      COLOR "b+/b"
  33.       @ 14 + IIF( lChannel, 0, 1 ), 28 SAY CHR( 26 ) COLOR "gr+/b"
  34.       DrawVol( 14, 44, nVolumeL )
  35.       DrawVol( 15, 44, nVolumeR )
  36.       aExit   := BoxMessage( "Esc-Exit",  16, 11, "b" )
  37.       aPlay   := BoxMessage( "F1-Play",   16, 23, "b" )
  38.       aStop   := BoxMessage( "F2-Stop",   16, 34, "b" )
  39.       aResume := BoxMessage( "F3-Resume", 16, 45, "b" )
  40.       aEject  := BoxMessage( "F4-Eject",  16, 58, "b" )
  41.       WHILE nKey != K_ESC
  42.         nKey := 0
  43.         WHILE nKey == 0
  44.           nKey := Inkey()
  45.           IF cdStatus() == CD_PLAYING
  46.             @ 14, 13 SAY replicate( "■", nJamp ) COLOR "r+/b"
  47.             @ 15, 13 SAY replicate( "■", nJamp ) COLOR "r+/b"
  48.             nJamp++
  49.             IF nJamp == 11
  50.               nJamp := 1
  51.               @ 14, 13 SAY replicate( "■", 10 ) COLOR "g+/b"
  52.               @ 15, 13 SAY replicate( "■", 10 ) COLOR "g+/b"
  53.             ENDIF
  54.           ENDIF
  55.         ENDDO
  56.         IF nKey == K_F1
  57.           BoxPush( aPlay )
  58.           aSongs := cdInfo()
  59.           IF LEN( aSongs ) > 1
  60.             aEval( aSongs, ;
  61.                    { | x, i | aSongs[ i ] := "Song " + ;
  62.                                              Str( i, 2 ) + ;
  63.                                              ". Time " + x } )
  64.             cScreen := SaveScreen( 10, 28, 17, 50 )
  65.             BoxOpen( 10, 28, 17, 50, "B" )
  66.             nSong := aChoice( 11, 30, 16, 49, aSongs, .T. )
  67.             RestScreen( 10, 28, 17, 50, cScreen )
  68.             IF nSong > 0 .AND. nSong <= LEN( aSongs )
  69.               cdPlay( nSong )
  70.             ENDIF
  71.           ENDIF
  72.         ELSEIF nKey == K_F2
  73.           BoxPush( aStop )
  74.           cdStop()
  75.         ELSEIF nKey == K_F3
  76.           BoxPush( aResume )
  77.           cdResume()
  78.         ELSEIF nKey == K_F4
  79.           BoxPush( aEject )
  80.           cdStop()
  81.           cdEject()
  82.         ELSEIF nKey == K_UP .OR. nKey == K_DOWN
  83.           @ 14 + IIF( lChannel, 0, 1 ), 28 SAY " "       COLOR "gr+/b"
  84.           lChannel := ! lChannel
  85.           @ 14 + IIF( lChannel, 0, 1 ), 28 SAY CHR( 26 ) COLOR "gr+/b"
  86.         ELSEIF nKey == K_LEFT
  87.           IF lChannel
  88.             IF nVolumeL > 0
  89.               nVolumeL--
  90.               sbCDVolL( nVolumeL )
  91.             ENDIF
  92.           ELSE
  93.             IF nVolumeR > 0
  94.               nVolumeR--
  95.               sbCDVolR( nVolumeR )
  96.             ENDIF
  97.           ENDIF
  98.           DrawVol( 14, 44, nVolumeL )
  99.           DrawVol( 15, 44, nVolumeR )
  100.         ELSEIF nKey == K_RIGHT
  101.           IF lChannel
  102.             IF nVolumeL < 15
  103.               nVolumeL++
  104.               sbCDVolL( nVolumeL )
  105.             ENDIF
  106.           ELSE
  107.             IF nVolumeR < 15
  108.               nVolumeR++
  109.               sbCDVolR( nVolumeR )
  110.             ENDIF
  111.           ENDIF
  112.           DrawVol( 14, 44, nVolumeL )
  113.           DrawVol( 15, 44, nVolumeR )
  114.         ENDIF
  115.       ENDDO
  116.       BoxPush( aExit )
  117.     ENDIF
  118.     SetCursor( nCursor )
  119.     RestScreen( 0, 0, 24, 79, cMain )
  120.     SetPos( nY, 0 )
  121. RETURN NIL
  122.  
  123.  
  124. STATIC FUNCTION DrawVol( nY, nX, nVol )
  125.     @ nY, nX        SAY REPLICATE( "■",      nVol ) COLOR "g+/b"
  126.     @ nY, nX + nVol SAY REPLICATE( "■", 15 - nVol ) COLOR "r+/b"
  127. RETURN NIL
  128.