static PRESULT win_mpegYT_player_key_proc(POBJECT_HEAD pObj, UINT32 key, UINT32 param) { PRESULT ret = PROC_LOOP; int wait_time = 0; if((key == V_KEY_PAUSE)&&(MPEGYTInfo.PlayState != MPEG_PLAY)) { key = V_KEY_PLAY; } switch (key) { case V_KEY_EXIT: case V_KEY_MENU: if (m_HideWindow) { if (m_bSetVol_YT) { //ShowVolumeBar(FALSE);//Close volume bar win_mpegYTplayer_close_video_vol(); m_bSetVol_YT = FALSE; } else { ret = PROC_LEAVE;//exit video player } } else { if (MPEGYTInfo.PlayState == MPEG_STOP) { ret = PROC_LEAVE;//exit video player } else { api_stop_timer(&mpegYT_timeout_id); win_mpegYT_player_draw(FALSE);//Hide the information window if (BarState.State == CURSOR_MOVING) { SyncBarPosAndCursor(POS_TO_CUR); } } } break; case V_KEY_PLAY: case V_KEY_1: if(MPEGYTInfo.PlayState != MPEG_PLAY) { PivotalKeyProc(); PlayProc_yt(); } break; case V_KEY_PAUSE: case V_KEY_2: case V_KEY_STEP: PivotalKeyProc(); PauseProc(); break; case V_KEY_STOP: case V_KEY_0: PivotalKeyProc(); StopProc(); ret = PROC_LEAVE; break; case V_KEY_LEFT: if (m_HideWindow) { win_mpegYT_player_draw(FALSE); win_mpegYTplayer_set_video_vol(V_KEY_LEFT); return PROC_LOOP; } if(s_is_in_parsing) { break; } if (MPEGYTInfo.PlayState != MPEG_STOP) { if (BarState.State != CURSOR_MOVING) { BarState.State = CURSOR_MOVING; BarState.nCursor = BarState.nPos; } if (BarState.nCursor > SLIDE_BAR_STEP) { BarState.nCursor -= SLIDE_BAR_STEP; } else if (0 == BarState.nCursor ) { if(BarState.nRange > SLIDE_BAR_STEP) BarState.nCursor = BarState.nRange-SLIDE_BAR_STEP; else BarState.nCursor = BarState.nRange; }else { BarState.nCursor = 0; } } win_mpegYT_player_draw(TRUE); break; case V_KEY_RIGHT: if (m_HideWindow) { win_mpegYT_player_draw(FALSE); win_mpegYTplayer_set_video_vol(V_KEY_RIGHT); return PROC_LOOP; } if(s_is_in_parsing) { break; } if (MPEGYTInfo.PlayState != MPEG_STOP) { if (BarState.State != CURSOR_MOVING) { BarState.State = CURSOR_MOVING; BarState.nCursor = BarState.nPos; } if (BarState.nCursor + SLIDE_BAR_STEP < BarState.nRange) { BarState.nCursor += SLIDE_BAR_STEP; } else { if(BarState.nRange > SLIDE_BAR_STEP) BarState.nCursor = SLIDE_BAR_STEP; else BarState.nCursor = BarState.nRange - VIDEO_SEARCH_DLYS; } } win_mpegYT_player_draw(TRUE); break; case V_KEY_ENTER: if (MPEGYTInfo.PlayState != MPEG_STOP) { if (BarState.State == CURSOR_MOVING) { if (BarState.nPos < BarState.nCursor)//forward { BarState.CursorDir = 1; } else if (BarState.nPos > BarState.nCursor)//backward { BarState.CursorDir = 2; } else { BarState.CursorDir = 0; } SyncBarPosAndCursor(CUR_TO_POS); MPEGYTInfo.PlayTime = BarState.nPos; if (BarState.CursorDir) { s_ytvideo_seektime = MPEGYTInfo.PlayTime; api_stop_timer(&mpegYT_refresh_id); libnet_download_abort(g_strf_cur_dl_rsrc); mpg_cmd_stop_proc(); mpegYT_file_prompt("Loading, please wait...", TRUE); osal_task_sleep(1000); UINT8 tmpurl[1024]; UINT8* tmppos; tmppos = strstr(url_youtube, "&begin="); if(NULL == tmppos) { sprintf(tmpurl, "&begin=%d", s_ytvideo_seektime * 1000); strcat(url_youtube, tmpurl); }else { sprintf(tmppos, "&begin=%d", s_ytvideo_seektime * 1000); } httpstrfile_url_gen(tmpurl, url_youtube, "mp4"); video_dec_file(tmpurl, 0); s_is_in_parsing = 1; MPEGYTInfo.PlaySpeed = 0; StartRefreshTimer(); } PlayProc_yt(); } } break; default: break; } return ret; }
static PRESULT win_mpeg_player_key_proc(POBJECT_HEAD pObj, UINT32 key, UINT32 param) { PRESULT ret = PROC_LOOP; int wait_time = 0; if((key == V_KEY_PAUSE)&&(MPEGInfo.PlayState != MPEG_PLAY)) { key = V_KEY_PLAY; } switch (key) { case V_KEY_EXIT: case V_KEY_MENU: if (m_HideWindow) { if (m_bSetVol) { //ShowVolumeBar(FALSE);//Close volume bar win_mpegplayer_close_video_vol(); m_bSetVol = FALSE; } else { ret = PROC_LEAVE;//exit video player } } else { if (MPEGInfo.PlayState == MPEG_STOP) { ret = PROC_LEAVE;//exit video player } else { api_stop_timer(&mpeg_timeout_id); win_mpeg_player_draw(FALSE);//Hide the information window if (BarState.State == CURSOR_MOVING) { SyncBarPosAndCursor(POS_TO_CUR); } } } break; case V_KEY_PLAY: case V_KEY_1: if(MPEGInfo.PlayState != MPEG_PLAY) { PivotalKeyProc(); PlayProc(); } break; case V_KEY_PAUSE: case V_KEY_2: case V_KEY_STEP: PivotalKeyProc(); PauseProc(); break; case V_KEY_STOP: case V_KEY_0: PivotalKeyProc(); StopProc(); ret = PROC_LEAVE; break; case V_KEY_PREV: case V_KEY_NEXT: break; case V_KEY_FF: if (MPEGInfo.PlayState == MPEG_STOP) { return PROC_LOOP; } else { PivotalKeyProc(); FastForwardProc(); } break; case V_KEY_FB: if (MPEGInfo.PlayState == MPEG_STOP) { return PROC_LOOP; } else { PivotalKeyProc(); FastBackwardProc(); } break; case V_KEY_SLOW: if (MPEGInfo.PlayState == MPEG_STOP) { return PROC_LOOP; } else { PivotalKeyProc(); SlowForwardProc(); } break; case V_KEY_LEFT: if (m_HideWindow) { win_mpeg_player_draw(FALSE); win_mpegplayer_set_video_vol(V_KEY_LEFT); return PROC_LOOP; } if (MPEGInfo.PlayState != MPEG_STOP) { if (BarState.State != CURSOR_MOVING) { BarState.State = CURSOR_MOVING; BarState.nCursor = BarState.nPos; } if (BarState.nCursor > SLIDE_BAR_STEP) { BarState.nCursor -= SLIDE_BAR_STEP; } else if (0 == BarState.nCursor ) { if(BarState.nRange > SLIDE_BAR_STEP) BarState.nCursor = BarState.nRange-SLIDE_BAR_STEP; else BarState.nCursor = BarState.nRange; } else { BarState.nCursor = 0; } } win_mpeg_player_draw(TRUE); break; case V_KEY_RIGHT: if (m_HideWindow) { win_mpeg_player_draw(FALSE); win_mpegplayer_set_video_vol(V_KEY_RIGHT); return PROC_LOOP; } if (MPEGInfo.PlayState != MPEG_STOP) { if (BarState.State != CURSOR_MOVING) { BarState.State = CURSOR_MOVING; BarState.nCursor = BarState.nPos; } if (BarState.nCursor + SLIDE_BAR_STEP < BarState.nRange) { BarState.nCursor += SLIDE_BAR_STEP; } else { if(BarState.nRange > SLIDE_BAR_STEP) BarState.nCursor = SLIDE_BAR_STEP; else BarState.nCursor = BarState.nRange - VIDEO_SEARCH_DLYS; } } win_mpeg_player_draw(TRUE); break; case V_KEY_ENTER: if (MPEGInfo.PlayState != MPEG_STOP) { if (BarState.State == CURSOR_MOVING) { if (BarState.nPos < BarState.nCursor)//forward { BarState.CursorDir = 1; } else if (BarState.nPos > BarState.nCursor)//backward { BarState.CursorDir = 2; } else { BarState.CursorDir = 0; } SyncBarPosAndCursor(CUR_TO_POS); MPEGInfo.PlayTime = BarState.nPos; if (BarState.CursorDir == 1)//forward { mpg_cmd_search_proc(MPEGInfo.PlayTime); while ((MPEGInfo.PlayTime > (UINT32)MPGFileDecoderGetPlayTime()) && (wait_time < 555)) { osal_task_sleep(2); wait_time++; } } else if (BarState.CursorDir == 2)//backward { mpg_cmd_search_proc(MPEGInfo.PlayTime); while ((MPEGInfo.PlayTime + VIDEO_SEARCH_DLYS < (UINT32)MPGFileDecoderGetPlayTime()) && (wait_time < 555)) { osal_task_sleep(2); wait_time++; } } PlayProc(); } } break; case V_KEY_INFOR: case V_KEY_PVR_INFO: m_HideWindow = !m_HideWindow; if (!m_HideWindow) { if (m_bSetVol)//if volume window is open, close it. { //ShowVolumeBar(FALSE); } win_mpeg_player_draw(TRUE); } else { win_mpeg_player_draw(FALSE); if (BarState.State == CURSOR_MOVING) { SyncBarPosAndCursor(POS_TO_CUR); } } break; case V_KEY_MUTE: break; } return ret; }