Read Current Volume of mediaplayer
Moderator: Rathinagiri
- Clip2Mania
- Posts: 99
- Joined: Fri Jun 13, 2014 7:16 am
- Location: Belgium
Read Current Volume of mediaplayer
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?
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
Hi,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?
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;
Code: Select all
...
CASE Arg3 == "VOLUME"
RetVal := _GetPlayerVolume ( Arg2 , Arg1 )
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 )
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Re: Read Current Volume of mediaplayer
#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
#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
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
- Clip2Mania
- Posts: 99
- Joined: Fri Jun 13, 2014 7:16 am
- Location: Belgium
Re: Read Current Volume of mediaplayer
thanks! Additional question
In what function in h_controlmisc.prg is that, please?
gfilatov wrote: and then get "Volume" property in your h_controlmisc.prg via a new property belowCode: 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
Hi,Clip2Mania wrote: In what function in h_controlmisc.prg is that, please?
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
...
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Re: Read Current Volume of mediaplayer
Find working sample
Replace source files, rebuild library and run example
Replace source files, rebuild library and run example
- Attachments
-
- PLAYER_3.rar
- (115.42 KiB) Downloaded 406 times
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
- Clip2Mania
- Posts: 99
- Joined: Fri Jun 13, 2014 7:16 am
- Location: Belgium
Re: Read Current Volume of mediaplayer
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 ???
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 ???
- Attachments
-
- PLAYER_2.rar
- (982.57 KiB) Downloaded 426 times
Re: Read Current Volume of mediaplayer
Hi,Clip2Mania wrote: however when I do "Form_1.Player_1.Volume" does not work ???
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
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
- Clip2Mania
- Posts: 99
- Joined: Fri Jun 13, 2014 7:16 am
- Location: Belgium
Re: Read Current Volume of mediaplayer
Ok, didn't know that. I am learning!gfilatov wrote: It is an expected behavior because you didn't update a header file with pseudo-OOP definitions.
I tried it just now, and this returns 'NIL'gfilatov wrote: Did you tried a function's calling equivalent
GetProperty( 'Form_1' , 'Player_1' , 'Volume' ) instead of pseudo-OOP using
As long as it works, it is fine.
Thank you and 'bpd2000' !
- Clip2Mania
- Posts: 99
- Joined: Fri Jun 13, 2014 7:16 am
- Location: Belgium
Re: Read Current Volume of mediaplayer
Together we are stronggfilatov wrote: It is an expected behavior because you didn't update a header file with pseudo-OOP definitions.
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"\> ) ;;
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?