MediaPlayer

Bagi yg suka mendengarkan music pasti dah tahu winap kan dan ini coding pemutar musik dengan rasa minigui extended

Coding pemutar music
/*
* MINIGUI – Harbour Win32 GUI library Demo
*
* Copyright 2002-06 Roberto Lopez
* http://harbourminigui.googlepages.com/
*
* Copyright 2003-06 Grigory Filatov
*/

ANNOUNCE RDDSYS

#include “minigui.ch”

#define PROGRAM ‘Easy Media Player’
#define VERSION ‘ version 1.2.2’
#define COPYRIGHT ‘ 2003-2006 Grigory Filatov’

#define IDI_MAIN 1001

#xcommand ON KEY SPACE [ OF ] ACTION ;
=> ;
_DefineHotKey ( , 0 , VK_SPACE , )

Static cFile := “”, nLenght := 0, lPause := .f., lNoSound := .f.

*—————————————————————————–*
Procedure Main()
*—————————————————————————–*

SET MULTIPLE OFF

DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 375 ;
HEIGHT IF(IsXPThemeActive(), 380, 370) ;
TITLE PROGRAM ;
ICON IDI_MAIN ;
MAIN ;
ON INIT DoMethod( “Form_1”, “Btn_1”, “SetFocus” ) ;
ON RELEASE DoMethod( “Form_1”, “Play_1”, “Release” ) ;
ON MAXIMIZE IF(cFileExt( cFile ) $ “MP3 WAV”, ;
SetProperty( “Form_1”, “Height”, ;
IF(IsXPThemeActive(), 120, 110), ;
DoMethod( “Form_1”, “Center” ) ), ) ;
ON SIZE ResizeCtrls( .t. ) ;
ON PAINT ResizeCtrls()

DEFINE MAIN MENU

POPUP “&File”

ITEM ‘&Open…’ + Chr(9) + ‘Ctrl+O’ ACTION OpenMedia()

ITEM ‘&Close’ ACTION ( cFile := “”, ;
Form_1.Btn_2.Enabled := !Empty(cFile), ;
Form_1.Btn_3.Enabled := !Empty(cFile), ;
Form_1.Btn_4.Enabled := !Empty(cFile), ;
Form_1.Slider_1.Value := 0, ;
Form_1.Play_1.Close, Form_1.Title := PROGRAM )

SEPARATOR

ITEM ‘E&xit’ + Chr(9) + ‘Alt+X’ ACTION ReleaseAllWindows()

END POPUP

POPUP “&View”

ITEM ‘Full &Screen’ + Chr(9) + ‘Alt+Enter’ ACTION FullScreen()

POPUP “&Aspect ratios”
ITEM ’16 : 9′ + Chr(9) + ‘Ctrl+1’ ACTION SetAspect( 780, 524 )
ITEM ‘ 4 : 3’ + Chr(9) + ‘Ctrl+2’ ACTION SetAspect( 780, 670 )
END POPUP

END POPUP

POPUP “&Playback”

ITEM ‘&Play/Pause’ + Chr(9) + ‘Space’ ACTION PlayPause()

POPUP “&Volume”
ITEM ‘&Up’ + Chr(9) + ‘Page Up’ ACTION VolumeUpDown( .T. )
ITEM ‘&Down’ + Chr(9) + ‘Page Down’ ACTION VolumeUpDown( .F. )
ITEM ‘&Mute’ + Chr(9) + ‘Ctrl+M’ ACTION MuteSound()
END POPUP

END POPUP

POPUP “&Help”

ITEM ‘A&bout’ ACTION MsgAbout()

END POPUP

END MENU

@ 0, 2 PLAYER Play_1 ;
WIDTH Form_1.Width – 12 ;
HEIGHT 286 FILE cFile ;
NOMENU NOOPEN ;
SHOWPOSITION

@ Form_1.Height – 75, 2 BUTTON Btn_1 ;
PICTURE “IDB_OPEN” ;
ACTION OpenMedia() ;
WIDTH 26 ;
HEIGHT 26 ;
FLAT

@ Form_1.Height – 75, 32 BUTTON Btn_2 ;
PICTURE “IDB_PLAY” ;
ACTION ( lPause := .f., ;
Form_1.Btn_3.Enabled := .t., ;
Form_1.Btn_4.Enabled := .t., ;
Form_1.Btn_2.Enabled := .f., ;
IF( IsControlDefined( Timer_1, Form_1 ), , ;
_DefineTimer( “Timer_1”, “Form_1”, 250, {|| CheckStop()} ) ), ;
Form_1.Slider_1.Value := _GetPlayerVolume( “Play_1”, “Form_1” ), ;
Form_1.Play_1.Play() ) ;
WIDTH 26 ;
HEIGHT 26 ;
FLAT

@ Form_1.Height – 75, 62 BUTTON Btn_3 ;
PICTURE “IDB_PAUSE” ;
ACTION ( lPause := .t., ;
Form_1.Btn_2.Enabled := .t., ;
Form_1.Btn_3.Enabled := .f., ;
Form_1.Play_1.Pause() ) ;
WIDTH 26 ;
HEIGHT 26 ;
FLAT

@ Form_1.Height – 75, 92 BUTTON Btn_4 ;
PICTURE “IDB_STOP” ;
ACTION ( lPause := .t., ;
Form_1.Btn_3.Enabled := .f., ;
Form_1.Btn_4.Enabled := .f., ;
Form_1.Play_1.Position := 0, ;
Form_1.Btn_2.Enabled := .t. ) ;
WIDTH 26 ;
HEIGHT 26 ;
FLAT

@ Form_1.Height – 75, 125 CHECKBUTTON Btn_5 ;
PICTURE “IDB_SOUND” ;
WIDTH 26 ;
HEIGHT 26 ;
VALUE lNoSound ;
ON CHANGE MuteSound()

@ Form_1.Height – 75, 158 SLIDER Slider_1 ;
RANGE 0, 1000 ;
VALUE 0 ;
WIDTH 206 ;
HEIGHT 26 ;
NOTICKS ;
ON CHANGE SetVolume( Form_1.Slider_1.Value ) ;
TOOLTIP “Change volume of sound”

Form_1.Btn_2.Enabled := !Empty(cFile)
Form_1.Btn_3.Enabled := !Empty(cFile)
Form_1.Btn_4.Enabled := !Empty(cFile)

ON KEY ALT+X ACTION Form_1.Release()

ON KEY ESCAPE ACTION IF( Empty(cFile), , ;
( Form_1.Btn_3.Enabled := .f., Form_1.Btn_4.Enabled := .f., ;
Form_1.Play_1.Stop(), Form_1.Btn_2.Enabled := .t., Form_1.Btn_2.SetFocus ) )

ON KEY ALT+RETURN ACTION FullScreen()

ON KEY CONTROL+O ACTION OpenMedia()

ON KEY CONTROL+M ACTION MuteSound()

ON KEY CONTROL+1 ACTION SetAspect( 780, 524 )

ON KEY CONTROL+2 ACTION SetAspect( 780, 670 )

ON KEY SPACE ACTION PlayPause()

ON KEY PRIOR ACTION VolumeUpDown( .T. )

ON KEY NEXT ACTION VolumeUpDown( .F. )

END WINDOW

CENTER WINDOW Form_1

ACTIVATE WINDOW Form_1

Return

*—————————————————————————–*
Static Procedure ResizeCtrls( lCenter )
*—————————————————————————–*
Local nWidth := Form_1.Width, nHeight := Form_1.Height
Local nHeightMin := IF(IsXPThemeActive(), 120, 110), ;
nCtrlPos := nHeight – IF(IsXPThemeActive(), 85, 75)

Default lCenter := .f.

IF lCenter .AND. nWidth < 370
Form_1.Width := 370
ENDIF
IF lCenter .AND. nHeight < nHeightMin
Form_1.Height := nHeightMin
ENDIF

Form_1.Play_1.Width := Form_1.Width – 12
Form_1.Play_1.Height := nHeight – IF(IsXPThemeActive(), 94, 84)

Form_1.Btn_1.Row := nCtrlPos
Form_1.Btn_2.Row := nCtrlPos
Form_1.Btn_3.Row := nCtrlPos
Form_1.Btn_4.Row := nCtrlPos
Form_1.Btn_5.Row := nCtrlPos
Form_1.Btn_5.Col := nWidth – 247

Form_1.Slider_1.Row := nCtrlPos
Form_1.Slider_1.Col := nWidth – 217

if lCenter
IF cFileExt( cFile ) $ "MP3 WAV"
Form_1.Height := nHeightMin
ENDIF
Form_1.Center()
endif

Return

*—————————————————————————–*
Procedure OpenMedia()
*—————————————————————————–*
Local cOpenFile := Getfile( { {"Media files", "*.avi;*.mpg;*.dat;*.mp3;*.wav"}, ;
{"All files", "*.*"} }, "Open a File" )

cFile := cOpenFile

Form_1.Play_1.Release

@ 0, 2 PLAYER Play_1 OF Form_1 ;
WIDTH Form_1.Width – 12 ;
HEIGHT 286 FILE cFile ;
NOMENU NOOPEN ;
SHOWPOSITION

IF Empty(cFile)

Form_1.Btn_2.Enabled := !Empty(cFile)
Form_1.Btn_3.Enabled := !Empty(cFile)
Form_1.Btn_4.Enabled := !Empty(cFile)
Form_1.Btn_1.SetFocus

nLenght := 0
Form_1.Title := PROGRAM
ELSE

Form_1.Btn_2.Enabled := .t.
Form_1.Btn_3.Enabled := .f.
Form_1.Btn_4.Enabled := .f.
Form_1.Btn_2.SetFocus

nLenght := _GetPlayerLength( "Play_1", "Form_1" )
Form_1.Title := cFileNoPath(cFile) + ' – ' + PROGRAM

IF cFileExt( cFile ) $ "MP3 WAV"
Form_1.Height := IF(IsXPThemeActive(), 120, 110)
ELSE
Form_1.Height := IF(IsXPThemeActive(), 380, 370)
ENDIF
ENDIF

RETURN

*—————————————————————————–*
Procedure VolumeUpDown ( lUp )
*—————————————————————————–*

SetVolume( Form_1.Slider_1.Value + IF( lUp, 50, -50 ) )

Form_1.Slider_1.Value := _GetPlayerVolume( "Play_1", "Form_1" )

RETURN

*—————————————————————————–*
Procedure SetVolume ( nVolume )
*—————————————————————————–*

IF !Empty(cFile)

IF nVolume 1000
nVolume := 1000
ENDIF

SET PLAYER Play_1 OF Form_1 VOLUME nVolume

IF IsWindowDefined( Form_2 )
SET PLAYER Play_1 OF Form_2 VOLUME nVolume
ENDIF

IF !Empty( nVolume ) .AND. lNoSound
lNoSound := .f.
SetChkBtnPicture()
ENDIF

ENDIF

RETURN

*—————————————————————————–*
Procedure MuteSound()
*—————————————————————————–*

lNoSound := !lNoSound

SetChkBtnPicture()

SetVolume( IF( lNoSound, 0, Form_1.Slider_1.Value ) )

RETURN

*—————————————————————————–*
Static Procedure SetChkBtnPicture()
*—————————————————————————–*

Form_1.Btn_5.Release

IF lNoSound

@ Form_1.Height – 75, Form_1.Width – 247 CHECKBUTTON Btn_5 OF Form_1 ;
PICTURE “IDB_NOSOUND” ;
WIDTH 26 ;
HEIGHT 26 ;
VALUE lNoSound ;
ON CHANGE MuteSound()

ELSE

@ Form_1.Height – 75, Form_1.Width – 247 CHECKBUTTON Btn_5 OF Form_1 ;
PICTURE “IDB_SOUND” ;
WIDTH 26 ;
HEIGHT 26 ;
VALUE lNoSound ;
ON CHANGE MuteSound()

ENDIF

Return

*—————————————————————————–*
Static Procedure SetAspect( nX, nY )
*—————————————————————————–*

IF cFileExt( cFile ) $ “AVI MPG DAT”

_SetWindowSizePos ( “Form_1” , , , nX , nY )

Form_1.Center()

ENDIF

Return

*—————————————————————————–*
Static Procedure PlayPause()
*—————————————————————————–*

IF !Empty(cFile)

IF Form_1.Btn_3.Enabled
lPause := .t.
Form_1.Btn_2.Enabled := .t.
Form_1.Btn_3.Enabled := .f.
Form_1.Play_1.Pause()
ELSE
lPause := .f.
Form_1.Btn_2.Enabled := .f.
Form_1.Btn_3.Enabled := .t.
Form_1.Play_1.Resume()
ENDIF

ENDIF

RETURN

*—————————————————————————–*
Static Procedure CheckStop()
*—————————————————————————–*

IF Form_1.Play_1.Position >= nLenght

IF IsControlDefined( Timer_1, Form_1 )
Form_1.Timer_1.Release()
ENDIF
lPause := .t.
Form_1.Btn_3.Enabled := .f.
Form_1.Btn_4.Enabled := .f.
Form_1.Btn_2.Enabled := .t.
Form_1.Btn_2.SetFocus()

ENDIF

RETURN

*—————————————————————————–*
Static Procedure FullScreen()
*—————————————————————————–*

IF !Empty(cFile) .AND. !lPause .AND. cFileExt( cFile ) $ “AVI MPG DAT”

DEFINE WINDOW Form_2 AT 0, 0 ;
WIDTH GetDesktopWidth() HEIGHT GetDesktopHeight() ;
TOPMOST NOSIZE NOCAPTION ;
ON INIT ( ShowCursor( .F. ), ;
_SetPlayerVolume( “Play_1”, “Form_2”, _GetPlayerVolume( “Play_1”, “Form_1” ) ), ;
DoMethod( “Form_1”, “Play_1”, “Pause” ), ;
_SetPlayerPosition( “Play_1”, “Form_2”, GetProperty( “Form_1”, “Play_1”, “Position” ) ), ;
DoMethod( “Form_2”, “Play_1”, “Play” ) ) ;
ON RELEASE ( ShowCursor( .T. ), ;
DoMethod( “Form_1”, “Play_1”, “Resume” ), ;
_SetPlayerPosition( “Play_1”, “Form_1”, GetProperty( “Form_2”, “Play_1”, “Position” ) ), ;
IF(GetProperty( “Form_2”, “Play_1”, “Position” ) >= nLenght, CheckStop(), DoMethod( “Form_1”, “Play_1”, “Play” )) )

@ 0, 0 PLAYER Play_1 ;
WIDTH Form_2.Width ;
HEIGHT Form_2.Height ;
FILE cFile ;
NOAUTOSIZEWINDOW ;
NOPLAYBAR

ON KEY ESCAPE ACTION Form_2.Release

ON KEY RETURN ACTION Form_2.Release

ON KEY ALT+RETURN ACTION Form_2.Release

ON KEY PRIOR ACTION VolumeUpDown( .T. )

ON KEY NEXT ACTION VolumeUpDown( .F. )

END WINDOW

ACTIVATE WINDOW Form_2

ENDIF

Return

*—————————————————————————–*
Function _GetPlayerVolume ( ControlName , ParentForm )
*—————————————————————————–*
Local h , mVar

mVar := ‘_’ + ParentForm + ‘_’ + ControlName
h := _HMG_aControlhandles [&mVar]

Return mcifunc ( h , 19 )

*—————————————————————————–*
Function _SetPlayerPosition ( ControlName , ParentForm , nPos )
*—————————————————————————–*
Local h , mVar

mVar := ‘_’ + ParentForm + ‘_’ + ControlName
h := _HMG_aControlhandles [&mVar]
mcifunc ( h , 20 , nPos )

Return Nil

*——————————————————–*
Function cFileExt( cPathMask )
*——————————————————–*
Local cExt := AllTrim( cFileNoPath( cPathMask ) )
Local n := RAt( “.”, cExt )

return Upper( AllTrim( If( n > 0 .and. Len( cExt ) > n, Right( cExt, Len( cExt ) – n ), “” ) ) )

*——————————————————–*
Static Function MsgAbout()
*——————————————————–*
return MsgInfo( padc(PROGRAM + VERSION, 40) + CRLF + ;
“Copyright ” + Chr(169) + COPYRIGHT + CRLF + CRLF + ;
hb_compiler() + CRLF + ;
version() + CRLF + ;
Left(MiniGuiVersion(), 28) + CRLF + CRLF + ;
padc(“This program is Freeware!”, 38) + CRLF + ;
padc(“Copying is allowed!”, 40), “About ” + PROGRAM, IDI_MAIN, .f. )

#pragma BEGINDUMP

#include
#include
#include “hbapi.h”
#include “hbapiitm.h”
#include
#include

HB_FUNC ( MCIFUNC )
{
HWND mcihand = (HWND) hb_parnl(1);
int func = hb_parni(2);
switch(func)
{
case 1: hb_retnl( MCIWndPlay(mcihand) ) ; break;
case 2: hb_retnl( MCIWndStop(mcihand) ) ; break;
case 3: hb_retnl( MCIWndPause(mcihand) ) ; break;
case 4: hb_retnl( MCIWndClose(mcihand) ) ; break;
case 5: MCIWndDestroy(mcihand) ; hb_retnl(0) ; break;
case 6: hb_retnl( MCIWndEject(mcihand) ) ; break;
case 7: hb_retnl( MCIWndEnd(mcihand) ) ; break;
case 8: hb_retnl( MCIWndHome(mcihand) ) ; break;
case 9: hb_retnl( MCIWndOpen(mcihand,hb_parc(3),NULL) ) ; break;
case 10: hb_retnl( MCIWndOpenDialog(mcihand) ) ; break;
case 11: hb_retnl( MCIWndPlayReverse(mcihand) ) ; break;
case 12: hb_retnl( MCIWndResume(mcihand) ) ; break;
case 13: MCIWndSetRepeat(mcihand,hb_parl(3) ) ; hb_retnl(0) ; break;
case 14: hb_retnl( MCIWndSetSpeed(mcihand,hb_parni(3)) ) ; break;
case 15: hb_retnl( MCIWndSetVolume(mcihand,hb_parni(3)) ) ; break;
case 16: MCIWndSetZoom(mcihand,hb_parni(3) ) ; hb_retnl(0) ; break;
case 17: hb_retnl( MCIWndGetLength(mcihand) ) ; break;
case 18: hb_retnl( MCIWndGetPosition(mcihand) ) ; break;
case 19: hb_retnl( MCIWndGetVolume(mcihand) ) ; break;
case 20: hb_retnl( MCIWndSeek(mcihand,hb_parni(3)) ) ; break;
default: hb_retnl( 0 ) ;
}
}

#pragma ENDDUMP

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: