Page 1 of 2
Read Current Volume of mediaplayer
Posted: Fri Sep 12, 2014 7:59 am
by Clip2Mania
Please look at the sample:
x:\hmg.3.3.1\SAMPLES\Controls\Player\PLAYER_2
I try to extend the example by
reading the current setting of the volume
I can
set the player volume with "Form_1.Player_1.Volume" but:
How can I
read the
current/initial volume?
nVal:=Form_1.Player_1.Volume gives an error, because apparently, the "Volume" property is read-only. (there's only a "_SetPlayerVolume" ?)
(unfortunately not indicated in the
HMG Manual)
Other way?
Re: Read Current Volume of mediaplayer
Posted: Fri Sep 12, 2014 8:25 am
by gfilatov
Clip2Mania wrote:Please look at the sample:
x:\hmg.3.3.1\SAMPLES\Controls\Player\PLAYER_2
I try to extend the example by
reading the current setting of the volume
I can
set the player volume with "Form_1.Player_1.Volume" but:
How can I
read the
current/initial volume?
nVal:=Form_1.Player_1.Volume gives an error, because apparently, the "Volume" property is read-only. (there's only a "_SetPlayerVolume" ?)
(unfortunately not indicated in the
HMG Manual)
Other way?
Hi,
You are right! It is a known limitation in a Player C-code in HMG.
There is a simple solution. Please add to your C-function MCIFUNC() in the source c_media.c the following line:
Code: Select all
...
case 19: hb_retnl( MCIWndGetVolume( mcihand ) ); break;
and then get "Volume" property in your h_controlmisc.prg via a new property below
Code: Select all
...
CASE Arg3 == "VOLUME"
RetVal := _GetPlayerVolume ( Arg2 , Arg1 )
where
Code: Select all
*-----------------------------------------------------------------------------*
function _GetPlayerVolume ( ControlName , ParentForm )
*-----------------------------------------------------------------------------*
Local h , mVar, nMCIVolume
mVar := '_' + ParentForm + '_' + ControlName
h := _HMG_SYSDATA [3] [&mVar]
nMCIVolume := mcifunc ( h , 19 )
Return( nMCIVolume )
Hope that helps
Re: Read Current Volume of mediaplayer
Posted: Fri Sep 12, 2014 8:39 am
by bpd2000
#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
Re: Read Current Volume of mediaplayer
Posted: Fri Sep 12, 2014 11:15 am
by Clip2Mania
thanks! Additional question
gfilatov wrote:
and then get "Volume" property in your h_controlmisc.prg via a new property below
Code: Select all
...
CASE Arg3 == "VOLUME"
RetVal := _GetPlayerVolume ( Arg2 , Arg1 )
In what function in h_controlmisc.prg is that, please?
Re: Read Current Volume of mediaplayer
Posted: Fri Sep 12, 2014 11:27 am
by gfilatov
Clip2Mania wrote:
In what function in h_controlmisc.prg is that, please?
Hi,
It is the function GetProperty ()
Code: Select all
Function GetProperty ( Arg1 , Arg2 , Arg3 , Arg4 , Arg5 , Arg6 , Arg7 , Arg8 )
...
ElseIf Arg3 == 'LENGTH'
RetVal := _GetPlayerLength ( Arg2 , Arg1 )
ElseIf Arg3 == 'POSITION'
RetVal := _GetPlayerPosition ( Arg2 , Arg1 )
ElseIf Arg3 == 'VOLUME' // ADD
RetVal := _GetPlayerVolume ( Arg2 , Arg1 ) // ADD
...
Re: Read Current Volume of mediaplayer
Posted: Fri Sep 12, 2014 1:03 pm
by bpd2000
Find working sample
Replace source files, rebuild library and run example
Re: Read Current Volume of mediaplayer
Posted: Fri Sep 12, 2014 1:37 pm
by Clip2Mania
Hi gfilatov,
modified everything as you mentioned, added the function to h_media.prg, rebuilt with BuildAllLib.bat, no errors when rebuilding.
Using bpd2000's call
_GetPlayerVolume( "Playername", "Formname" ) works,
however when I do "Form_1.Player_1.Volume" does not work ???
Re: Read Current Volume of mediaplayer
Posted: Fri Sep 12, 2014 2:13 pm
by gfilatov
Clip2Mania wrote:
however when I do "Form_1.Player_1.Volume" does not work ???
Hi,
It is an expected behavior because you didn't update a header file with pseudo-OOP definitions.
Did you tried a function's calling equivalent
GetProperty( 'Form_1' , 'Player_1' , 'Volume' ) instead of pseudo-OOP using
Re: Read Current Volume of mediaplayer
Posted: Fri Sep 12, 2014 3:31 pm
by Clip2Mania
gfilatov wrote:
It is an expected behavior because you didn't update a header file with pseudo-OOP definitions.
Ok, didn't know that. I am learning!
gfilatov wrote:
Did you tried a function's calling equivalent
GetProperty( 'Form_1' , 'Player_1' , 'Volume' ) instead of pseudo-OOP using
I tried it just now, and this returns 'NIL'
As long as it works, it is fine.
Thank you and 'bpd2000' !
Re: Read Current Volume of mediaplayer
Posted: Fri Sep 12, 2014 4:41 pm
by Clip2Mania
gfilatov wrote:
It is an expected behavior because you didn't update a header file with pseudo-OOP definitions.
Together we are strong
Found the location to adapt:
in i_window.ch, change line 78 (add 'volume') to:
Code: Select all
#xtranslate <w> . \<c\> . \<p:Name,Length,Volume\> => GetProperty ( <"w">, \<"c"\> , \<"p"\> ) ;;
Again, thx for the help, guys!
I use this setting to save in an .ini file, so that next time I start my mediaplayer, it starts at the same volume I as last time.
Could this be added to the following 'official' release of hmg?