Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi ,

I am working on a video application. So I can pause and resume the video by preessing 2 different keys. But I would like to do this by 1 key. Basically i want to toggle keys . How can I do that?

Thanks.

try to add a flag in your applet and swap its value when you press the key you want to use to stop/play the video. :cool:

try to add a flag in your applet and swap its value when you press the key you want to use to stop/play the video. :cool:

Thanks so much for your reply. I am trying to add a variable with if condition for this task to be done. But it is not working. The code is as follows :
void CVideoDlg::HandleEvent(AEEEvent eCode, uint16 wParam, uint32 dwParam, boolean& res)
{
........
boolean state = FALSE;
switch(eCode) {
case EVT_KEY:
switch(wParam) {
..................
case AVK_UP:
if(state)
{
state = FALSE;
m_pVideo->Pause();// m_PVideo is a VideoObject Object
res = TRUE;
break;
}
else
{
state = TRUE;
m_pVideo->Resume();
res = TRUE;
break;
}
}
So could you please take a look on the above code and could you be please be more specific?I am new to BREW :confused:
Thanks so much in advance..I appreciate.

Thanks so much for your reply. I am trying to add a variable with if condition for this task to be done. But it is not working. The code is as follows :
void CVideoDlg::HandleEvent(AEEEvent eCode, uint16 wParam, uint32 dwParam, boolean& res)
{
........
boolean state = FALSE;
switch(eCode) {
case EVT_KEY:
switch(wParam) {
..................
case AVK_UP:
if(state)
{
state = FALSE;
m_pVideo->Pause();// m_PVideo is a VideoObject Object
res = TRUE;
break;
}
else
{
state = TRUE;
m_pVideo->Resume();
res = TRUE;
break;
}
}
So could you please take a look on the above code and could you be please be more specific?I am new to BREW :confused:
Thanks so much in advance..I appreciate.

The problem I see here is that your state variable is local. It means that every time you go into HandleEvent it will have the same value assigned in the local scope. Put the state variable as an attribute of your class and use this->state to access the persistent value. In your class constructor put the code this->state = FALSE, don't do it in the handleEvent. Your code should look like this:
void CVideoDlg::HandleEvent(AEEEvent eCode, uint16 wParam, uint32 dwParam, boolean& res)
{
........
// Don't do this here, do this inside the CVideoDlg class constructor
// boolean state = FALSE; // wrong way to do it
switch(eCode) {
case EVT_KEY:
switch(wParam) {
..................
case AVK_UP:
if(this->state)
{
this->state = FALSE;
m_pVideo->Pause();// m_PVideo is a VideoObject Object
res = TRUE;
break;

else
{
this->state = TRUE;
m_pVideo->Resume();
res = TRUE;
break;

The problem I see here is that your state variable is local. It means that every time you go into HandleEvent it will have the same value assigned in the local scope. Put the state variable as an attribute of your class and use this->state to access the persistent value. In your class constructor put the code this->state = FALSE, don't do it in the handleEvent. Your code should look like this:
void CVideoDlg::HandleEvent(AEEEvent eCode, uint16 wParam, uint32 dwParam, boolean& res)
{
........
// Don't do this here, do this inside the CVideoDlg class constructor
// boolean state = FALSE; // wrong way to do it
switch(eCode) {
case EVT_KEY:
switch(wParam) {
..................
case AVK_UP:
if(this->state)
{
this->state = FALSE;
m_pVideo->Pause();// m_PVideo is a VideoObject Object
res = TRUE;
break;

else
{
this->state = TRUE;
m_pVideo->Resume();
res = TRUE;
break;

does your video class have a IsPaused() or Playing() call, if so you could just check that and toggle it depending , then you wouldn't need a state saved, and there would be no sync problems.

does your video class have a IsPaused() or Playing() call, if so you could just check that and toggle it depending , then you wouldn't need a state saved, and there would be no sync problems.

Eonio wrote:The problem I see here is that your state variable is local. It means that every time you go into HandleEvent it will have the same value assigned in the local scope. Put the state variable as an attribute of your class and use this->state to access the persistent value. In your class constructor put the code this->state = FALSE, don't do it in the handleEvent.
Hello Eonio,
It works man! :D Awesome. Actually I made that changes already to declare the "state" variable in class attribute before I see your reply. But I wasn't using "this" pointer. So the pause/resume was only doing once by pressing the AVK key. But now by using "this" pointer I can make pause/resume over and over again with the same key. Hurray :D
Thanks so much.

Eonio wrote:The problem I see here is that your state variable is local. It means that every time you go into HandleEvent it will have the same value assigned in the local scope. Put the state variable as an attribute of your class and use this->state to access the persistent value. In your class constructor put the code this->state = FALSE, don't do it in the handleEvent.
Hello Eonio,
It works man! :D Awesome. Actually I made that changes already to declare the "state" variable in class attribute before I see your reply. But I wasn't using "this" pointer. So the pause/resume was only doing once by pressing the AVK key. But now by using "this" pointer I can make pause/resume over and over again with the same key. Hurray :D
Thanks so much.

charliex wrote:does your video class have a IsPaused() or Playing() call, if so you could just check that and toggle it depending , then you wouldn't need a state saved, and there would be no sync problems.
Thanks so much for your valuable advice. :)

charliex wrote:does your video class have a IsPaused() or Playing() call, if so you could just check that and toggle it depending , then you wouldn't need a state saved, and there would be no sync problems.
Thanks so much for your valuable advice. :)

farhana,
Charliex idea is better! Try to use your player class internal state to avoid sync events problem.
:D

farhana,
Charliex idea is better! Try to use your player class internal state to avoid sync events problem.
:D