INT32 UIFlowWndPlay_OnKeyEnter(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray)
{
  static BOOL bFirstEnter = TRUE;

    switch(g_PlbData.State)
    {
    case PLB_ST_FULL:
        if(UIPlay_GetData(PLAY_CURRMODE)==PLAYMODE_AVI)
        {
            if(bFirstEnter)
            {
                g_uiUIFlowWndPlayCurrentVolume = GetAudioVolume();
                bFirstEnter = FALSE;
            }
            KeyScan_EnableAutoPoweroff(FALSE);
            KeyScan_EnableUSBDet(FALSE);
            KeyScan_EnableKeyTone(FALSE);
            Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_AUD_VOLUME,1,g_uiUIFlowWndPlayCurrentVolume);
            Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_MOVPLAY,1,UIFlowMoviePlayCBFunc);
            g_PlbData.State = PLB_ST_PLAY_MOV;
            FlowPB_IconDrawMovPlay(TRUE);
            if (KeyScan_IsHDMIPlugIn()==FALSE)
            {
                FlowPB_IconDrawMovPlayVolumn(g_uiUIFlowWndPlayCurrentVolume);
            }
            FlowPB_IconDrawMovSpeed(0);
        }
        break;
    case PLB_ST_PLAY_MOV:
    case PLB_ST_FWD_MOV:
    case PLB_ST_BWD_MOV:
        if(UIPlay_GetData(PLAY_CURRMODE)==PLAYMODE_AVI)
        {
            Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_MOVPAUSE,0);
            g_PlbData.State = PLB_ST_PAUSE_MOV;
            KeyScan_EnableAutoPoweroff(TRUE);
            KeyScan_EnableUSBDet(TRUE);
            KeyScan_EnableKeyTone(SysGetFlag(FL_BEEP));
            FlowPB_IconDrawMovPlay(TRUE);
            FlowPB_IconDrawMovSpeed(0);
        }
        break;
    case PLB_ST_PAUSE_MOV:
        if(UIPlay_GetData(PLAY_CURRMODE)==PLAYMODE_AVI)
        {
            KeyScan_EnableAutoPoweroff(FALSE);
            KeyScan_EnableUSBDet(FALSE);
            KeyScan_EnableKeyTone(FALSE);
            Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_MOVRESUME,0);
            g_PlbData.State = PLB_ST_PLAY_MOV;
            FlowPB_IconDrawMovPlay(TRUE);
            FlowPB_IconDrawMovSpeed(0);
        }
        break;
    }
    return NVTEVT_CONSUME;
}
INT32 UIFlowWndPlay_OnKeyRight(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray)
{
    switch(g_PlbData.State)
    {
        case PLB_ST_FULL:
            Input_SetKeyMask(KEY_PRESS, FLGKEY_KEY_MASK_NULL);
            Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_PLAYSINGLE, 2, PB_SINGLE_NEXT, 1);
            FlowPB_UpdateIcons(1);
            UIFlowWndPlay_CheckStatus();
            Input_SetKeyMask(KEY_PRESS, FLGKEY_KEY_MASK_DEFAULT);
            break;
        case PLB_ST_PLAY_MOV:
        case PLB_ST_FWD_MOV:
        case PLB_ST_BWD_MOV:
#if(_MODEL_DSC_== _MODEL_DUAL_NAZHIDA_)		
        //#NT#2012/08/31#Calvin Chang#Porting Media Flow -begin
        if(g_PlbData.VideoPBSpeed > PLB_BWD_MOV_8x)
        {
            g_PlbData.VideoPBSpeed --;

            Ux_FlushEventByRange(NVTEVT_KEY_EVT_START,NVTEVT_KEY_EVT_END);
            Input_SetKeyMask(KEY_PRESS, FLGKEY_KEY_MASK_NULL);


            if(g_PlbData.VideoPBSpeed > PLB_FWD_MOV_1x)
            {
                g_PlbData.State = PLB_ST_FWD_MOV;
                UIFlowMoviePlay_SetSpeed(g_PlbData.VideoPBSpeed);
                g_uiUIFlowWndPlayCurrenDirection = MEDIAPLAY_DIR_FORWARD;

                // Play
                Ux_SendEvent(&UIMoviePlayObjCtrl,
                             NVTEVT_PLAY_PLAY_MOVIE,
                             2,
                             g_uiUIFlowWndPlayCurrenSpeed,
                             g_uiUIFlowWndPlayCurrenDirection);
            }
            else if(g_PlbData.VideoPBSpeed < PLB_FWD_MOV_1x)
            {
                g_PlbData.State = PLB_ST_BWD_MOV;
                UIFlowMoviePlay_SetSpeed(g_PlbData.VideoPBSpeed);
                g_uiUIFlowWndPlayCurrenDirection = MEDIAPLAY_DIR_BACKWARD;

                // Play
                Ux_SendEvent(&UIMoviePlayObjCtrl,
                             NVTEVT_PLAY_PLAY_MOVIE,
                             2,
                             g_uiUIFlowWndPlayCurrenSpeed,
                             g_uiUIFlowWndPlayCurrenDirection);

            }
            else   //uiCurrSpeedIndex == PLAYMOV_SPEED_FWD_1X
            {
                g_PlbData.State = PLB_ST_PLAY_MOV;
                UIFlowMoviePlay_SetSpeed(g_PlbData.VideoPBSpeed);
                g_uiUIFlowWndPlayCurrenDirection = MEDIAPLAY_DIR_FORWARD;

                // Play
                Ux_SendEvent(&UIMoviePlayObjCtrl,
                             NVTEVT_PLAY_PLAY_MOVIE,
                             2,
                             g_uiUIFlowWndPlayCurrenSpeed,
                             g_uiUIFlowWndPlayCurrenDirection);
            }

            FlowPB_IconDrawMovSpeed();
            Input_SetKeyMask(KEY_PRESS, FLGKEY_KEY_MASK_DEFAULT);
        }
            break;		
#else		
            //#NT#2012/08/31#Calvin Chang#Porting Media Flow -begin
            if(g_PlbData.VideoPBSpeed < PLB_FWD_MOV_8x)
            {
                g_PlbData.VideoPBSpeed ++;

                Ux_FlushEventByRange(NVTEVT_KEY_EVT_START,NVTEVT_KEY_EVT_END);
                Input_SetKeyMask(KEY_PRESS, FLGKEY_KEY_MASK_NULL);

                if(g_PlbData.VideoPBSpeed > PLB_FWD_MOV_1x)
                {
                    g_PlbData.State = PLB_ST_FWD_MOV;
                    UIFlowMoviePlay_SetSpeed(g_PlbData.VideoPBSpeed);
                    g_uiUIFlowWndPlayCurrenDirection = MEDIAPLAY_DIR_FORWARD;

                    // Play
                    Ux_SendEvent(&UIMoviePlayObjCtrl,
                                 NVTEVT_PLAY_PLAY_MOVIE,
                                 2,
                                 g_uiUIFlowWndPlayCurrenSpeed,
                                 g_uiUIFlowWndPlayCurrenDirection);
                }
                else if(g_PlbData.VideoPBSpeed < PLB_FWD_MOV_1x)
                {
                    g_PlbData.State = PLB_ST_BWD_MOV;
                    UIFlowMoviePlay_SetSpeed(g_PlbData.VideoPBSpeed);
                    g_uiUIFlowWndPlayCurrenDirection = MEDIAPLAY_DIR_BACKWARD;

                    // Play
                    Ux_SendEvent(&UIMoviePlayObjCtrl,
                                 NVTEVT_PLAY_PLAY_MOVIE,
                                 2,
                                 g_uiUIFlowWndPlayCurrenSpeed,
                                 g_uiUIFlowWndPlayCurrenDirection);

                }
                else   //uiCurrSpeedIndex == PLAYMOV_SPEED_FWD_1X
                {
                    g_PlbData.State = PLB_ST_PLAY_MOV;
                    UIFlowMoviePlay_SetSpeed(g_PlbData.VideoPBSpeed);
                    g_uiUIFlowWndPlayCurrenDirection = MEDIAPLAY_DIR_FORWARD;

                    // Play
                    Ux_SendEvent(&UIMoviePlayObjCtrl,
                                 NVTEVT_PLAY_PLAY_MOVIE,
                                 2,
                                 g_uiUIFlowWndPlayCurrenSpeed,
                                 g_uiUIFlowWndPlayCurrenDirection);
                }
                FlowPB_IconDrawMovSpeed();
                Input_SetKeyMask(KEY_PRESS, FLGKEY_KEY_MASK_DEFAULT);
            }
            break;
            //#NT#2012/08/31#Calvin Chang -end
#endif            
//#NT#2012/7/6#Philex mark temp
#if 0
        if (KeyScan_IsHDMIPlugIn()==FALSE) {
            if(g_PlbData.VideoPBSpeed < PLB_FWD_MOV_8x)
            {
                g_PlbData.VideoPBSpeed ++;

                Ux_FlushEvent();
                KeyScan_SetKeyMask(KEYSCAN_KEYMODE_PRESS, FLGKEY_KEY_MASK_NULL);

                if(g_PlbData.VideoPBSpeed > PLB_FWD_MOV_1x)
                {
                    Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_MOVFWD,1,g_PlbData.VideoPBSpeed);
                    g_PlbData.State = PLB_ST_FWD_MOV;
                    // set mute in FWD playing
                    hdmitx_setAudMute(TRUE);
                }
                else if(g_PlbData.VideoPBSpeed < PLB_FWD_MOV_1x)
                {
                    Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_MOVBWD,1,g_PlbData.VideoPBSpeed);
                    g_PlbData.State = PLB_ST_BWD_MOV;
                    // set mute in BWD playing
                    hdmitx_setAudMute(TRUE);
                }
                else   //uiCurrSpeedIndex == PLAYMOV_SPEED_FWD_1X
                {
                    Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_MOVFWDSTOP,0);
                    g_PlbData.State = PLB_ST_PLAY_MOV;
                    /* Since Media FWD/BWD will set volume mute, we should restore current volume. */
                    hdmitx_setAudMute(FALSE);
                    Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_AUD_VOLUME,1,g_uiUIFlowWndPlayCurrentVolume);
                }

                FlowPB_IconDrawMovSpeed();
                KeyScan_SetKeyMask(KEYSCAN_KEYMODE_PRESS, FLGKEY_KEY_MASK_DEFAULT);
            }
        }
        break;
#endif

    }
    return NVTEVT_CONSUME;
}
INT32 UIFlowWndPlay_OnKeyRight(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray)
{
UINT32 uiActKey;

    if (paramNum >= 1)
        uiActKey = paramArray[0];

    switch (uiActKey)
    {
      case NVTEVT_KEY_PRESS:
    switch(g_PlbData.State)
    {
    case PLB_ST_FULL:
        KeyScan_SetKeyMask(KEYSCAN_KEYMODE_PRESS, FLGKEY_KEY_MASK_NULL);
        Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_PLAYNEXT,0);
        FlowPB_UpdateIcons(1);
        KeyScan_SetKeyMask(KEYSCAN_KEYMODE_PRESS, FLGKEY_KEY_MASK_DEFAULT);
        break;
    case PLB_ST_PLAY_MOV:
    case PLB_ST_FWD_MOV:
    case PLB_ST_BWD_MOV:
    #if 0
        if(!KeyScan_IsHDMIPlugIn())   //Not allow volume change when HDMI plugged in
                    {
                     //debug_err(("henry--------------down\r\n"));
                        if(g_uiUIFlowWndPlayCurrentVolume > AUDIO_VOL_MUTE)
                        {
                            g_uiUIFlowWndPlayCurrentVolume--;
                            Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_AUD_VOLUME,1,g_uiUIFlowWndPlayCurrentVolume);
                            FlowPB_IconDrawMovPlayVolumn(g_uiUIFlowWndPlayCurrentVolume);
                        }
                    }
    #endif
      //if (KeyScan_IsHDMIPlugIn()==FALSE) {
            if(g_PlbData.VideoPBSpeed < PLB_FWD_MOV_8x)
            {
                g_PlbData.VideoPBSpeed ++;

                Ux_FlushEvent();
                KeyScan_SetKeyMask(KEYSCAN_KEYMODE_PRESS, FLGKEY_KEY_MASK_NULL);

                if(g_PlbData.VideoPBSpeed > PLB_FWD_MOV_1x)
                {
                    Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_MOVFWD,1,g_PlbData.VideoPBSpeed);
                    g_PlbData.State = PLB_ST_FWD_MOV;
                    // set mute in FWD playing
                    hdmitx_setAudMute(TRUE);
                }
                else if(g_PlbData.VideoPBSpeed < PLB_FWD_MOV_1x)
                {
                    Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_MOVBWD,1,g_PlbData.VideoPBSpeed);
                    g_PlbData.State = PLB_ST_BWD_MOV;
                    // set mute in BWD playing
                    hdmitx_setAudMute(TRUE);
                }
                else   //uiCurrSpeedIndex == PLAYMOV_SPEED_FWD_1X
                {
                    Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_MOVFWDSTOP,0);
                    g_PlbData.State = PLB_ST_PLAY_MOV;
                    
                    hdmitx_setAudMute(FALSE);
                    Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_AUD_VOLUME,1,g_uiUIFlowWndPlayCurrentVolume);
                }

                FlowPB_IconDrawMovSpeed();
                KeyScan_SetKeyMask(KEYSCAN_KEYMODE_PRESS, FLGKEY_KEY_MASK_DEFAULT);
            }
        //}
        break;
    }
    break;
        }
    return NVTEVT_CONSUME;
}
INT32 UIFlowWndPlay_OnKeyLeft(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray)
{
    switch(g_PlbData.State)
    {
    case PLB_ST_FULL:
        Input_SetKeyMask(KEY_PRESS, FLGKEY_KEY_MASK_NULL);
        Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_PLAYSINGLE, 2, PB_SINGLE_PREV, 1);
        FlowPB_UpdateIcons(1);
        UIFlowWndPlay_CheckStatus();
        Input_SetKeyMask(KEY_PRESS, FLGKEY_KEY_MASK_DEFAULT);
        break;
    case PLB_ST_PLAY_MOV:
    case PLB_ST_FWD_MOV:
    case PLB_ST_BWD_MOV:
        //#NT#2012/08/31#Calvin Chang#Porting Media Flow -begin
        //if(g_PlbData.VideoPBSpeed > PLB_BWD_MOV_8x)
        if(g_PlbData.VideoPBSpeed > PLB_BWD_MOV_4x)
        {
            g_PlbData.VideoPBSpeed --;

            Ux_FlushEventByRange(NVTEVT_KEY_EVT_START,NVTEVT_KEY_EVT_END);
            Input_SetKeyMask(KEY_PRESS, FLGKEY_KEY_MASK_NULL);


            if(g_PlbData.VideoPBSpeed > PLB_FWD_MOV_1x)
            {
                g_PlbData.State = PLB_ST_FWD_MOV;
                UIFlowMoviePlay_SetSpeed(g_PlbData.VideoPBSpeed);
                g_uiUIFlowWndPlayCurrenDirection = MEDIAPLAY_DIR_FORWARD;
				
                UxState_SetData(&UIFlowWndPlay_StatusICN_MovFwdCtrl,STATE_CURITEM,UIFlowWndPlay_StatusICN_MovFwd_ICON_FF_RIGHT_BLUE);
                UxCtrl_SetShow(&UIFlowWndPlay_StatusICN_MovFwdCtrl, TRUE);
                // Play
                Ux_SendEvent(&UIMoviePlayObjCtrl,
                             NVTEVT_PLAY_PLAY_MOVIE,
                             2,
                             g_uiUIFlowWndPlayCurrenSpeed,
                             g_uiUIFlowWndPlayCurrenDirection);
            }
            else if(g_PlbData.VideoPBSpeed < PLB_FWD_MOV_1x)
            {
                g_PlbData.State = PLB_ST_BWD_MOV;
                UIFlowMoviePlay_SetSpeed(g_PlbData.VideoPBSpeed);
                g_uiUIFlowWndPlayCurrenDirection = MEDIAPLAY_DIR_BACKWARD;

                 UxState_SetData(&UIFlowWndPlay_StatusICN_MovBwdCtrl,STATE_CURITEM,UIFlowWndPlay_StatusICN_MovBwd_ICON_FB_LEFT_BLUE);
                UxCtrl_SetShow(&UIFlowWndPlay_StatusICN_MovBwdCtrl, TRUE);
				
                // Play
                Ux_SendEvent(&UIMoviePlayObjCtrl,
                             NVTEVT_PLAY_PLAY_MOVIE,
                             2,
                             g_uiUIFlowWndPlayCurrenSpeed,
                             g_uiUIFlowWndPlayCurrenDirection);

            }
            else   //uiCurrSpeedIndex == PLAYMOV_SPEED_FWD_1X
            {
                g_PlbData.State = PLB_ST_PLAY_MOV;
                UIFlowMoviePlay_SetSpeed(g_PlbData.VideoPBSpeed);
                g_uiUIFlowWndPlayCurrenDirection = MEDIAPLAY_DIR_FORWARD;
                 UxState_SetData(&UIFlowWndPlay_StatusICN_MovBwdCtrl,STATE_CURITEM,UIFlowWndPlay_StatusICN_MovBwd_ICON_FB_LEFT);
                UxCtrl_SetShow(&UIFlowWndPlay_StatusICN_MovBwdCtrl, TRUE);

                UxState_SetData(&UIFlowWndPlay_StatusICN_MovFwdCtrl,STATE_CURITEM,UIFlowWndPlay_StatusICN_MovFwd_ICON_FF_RIGHT);
                UxCtrl_SetShow(&UIFlowWndPlay_StatusICN_MovFwdCtrl, TRUE);
                // Play
                Ux_SendEvent(&UIMoviePlayObjCtrl,
                             NVTEVT_PLAY_PLAY_MOVIE,
                             2,
                             g_uiUIFlowWndPlayCurrenSpeed,
                             g_uiUIFlowWndPlayCurrenDirection);
            }

            FlowPB_IconDrawMovSpeed();
            Input_SetKeyMask(KEY_PRESS, FLGKEY_KEY_MASK_DEFAULT);
        }
        //#NT#2012/08/31#Calvin Chang -end
#if 0
        if (KeyScan_IsHDMIPlugIn()==FALSE) {
            if(g_PlbData.VideoPBSpeed < PLB_FWD_MOV_8x)
            {
                g_PlbData.VideoPBSpeed ++;

                Ux_FlushEvent();
                Input_SetKeyMask(KEY_PRESS, FLGKEY_KEY_MASK_NULL);

                if(g_PlbData.VideoPBSpeed > PLB_FWD_MOV_1x)
                {
                    Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_MOVFWD,1,g_PlbData.VideoPBSpeed);
                    g_PlbData.State = PLB_ST_FWD_MOV;
                    // set mute in FWD playing
                    hdmitx_setAudMute(TRUE);
                }
                else if(g_PlbData.VideoPBSpeed < PLB_FWD_MOV_1x)
                {
                    Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_MOVBWD,1,g_PlbData.VideoPBSpeed);
                    g_PlbData.State = PLB_ST_BWD_MOV;
                    // set mute in BWD playing
                    hdmitx_setAudMute(TRUE);
                }
                else   //uiCurrSpeedIndex == PLAYMOV_SPEED_FWD_1X
                {
                    Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_MOVFWDSTOP,0);
                    g_PlbData.State = PLB_ST_PLAY_MOV;
                    /* Since Media FWD/BWD will set volume mute, we should restore current volume. */
                    hdmitx_setAudMute(FALSE);
                    Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_AUD_VOLUME,1,g_uiUIFlowWndPlayCurrentVolume);
                }

                FlowPB_IconDrawMovSpeed();
                Input_SetKeyMask(KEY_PRESS, FLGKEY_KEY_MASK_DEFAULT);
            }
        }
#endif
        break;
    }
    return NVTEVT_CONSUME;
}