Skip to content

Commit

Permalink
improve play key handle
Browse files Browse the repository at this point in the history
  • Loading branch information
fgl27 committed Oct 26, 2024
1 parent ffdedf5 commit b1fd6c9
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 25 deletions.
2 changes: 1 addition & 1 deletion app/specific/ChannelContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ function ChannelContent_keyEnter() {
Main_values.Play_isHost = false;

Main_hideScene1Doc();
Main_addEventListener('keydown', Play_handleKeyDown);
Main_PlayHandleKeyDown();
Main_showScene2Doc();
Play_hidePanel();
Play_Start(true);
Expand Down
8 changes: 1 addition & 7 deletions app/specific/ChatLiveControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,7 @@ function ChatLiveControls_Show() {
function ChatLiveControls_Hide() {
ChatLiveControls_Channel = 0;
ChatLiveControls_PreventInputClear();
Main_removeEventListener('keydown', ChatLiveControls_KeyboardEvent);
Main_removeEventListener('keydown', ChatLiveControls_handleKeyDown);
Main_removeEventListener('keydown', ChatLiveControls_EmotesEvent);
Main_removeEventListener('keydown', ChatLiveControls_ChooseChat);
Main_removeEventListener('keydown', ChatLiveControls_OptionsKeyDown);

Main_addEventListener('keydown', Play_handleKeyDown);
Main_PlayHandleKeyDown();

Main_HideElement('chat_send');
Main_HideElement('chat_emotes_holder');
Expand Down
44 changes: 36 additions & 8 deletions app/specific/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,7 @@ function Main_OPenAsVod_PreshutdownStream() {
function Main_openStream() {
Main_hideScene1DocAndCallBack(function () {
Main_showScene2Doc();
Main_addEventListener('keydown', Play_handleKeyDown);
Main_PlayHandleKeyDown();

if (!Play_EndDialogEnter) {
Play_HideEndDialog();
Expand Down Expand Up @@ -1796,7 +1796,7 @@ function Main_OpenClip(data, id, idsArray, handleKeyDownFunction, screen) {
Main_hideScene1DocAndCallBack(function () {
Main_showScene2Doc();

Main_addEventListener('keydown', PlayClip_handleKeyDown);
Main_PlayClipHandleKeyDown();
PlayClip_Start();

Main_EventPlay('clip', Main_values_Play_data[6], Main_values_Play_data[3], Main_values_Play_data[17], screen);
Expand Down Expand Up @@ -1847,13 +1847,44 @@ function Main_OpenVodStart(data, id, idsArray, handleKeyDownFunction, screen) {
function Main_openVod() {
Main_hideScene1DocAndCallBack(function () {
Main_showScene2Doc();

Main_addEventListener('keydown', PlayVod_handleKeyDown);
Main_PlayVodHandleKeyDown();
Play_hideChat();
PlayVod_Start();
});
}

//center all player key events in one place to prevent key leaks
function Main_PlayVodHandleKeyDown() {
Main_clearAllPlayerEvents();
Main_addEventListener('keydown', PlayVod_handleKeyDown);
}

function Main_PlayClipHandleKeyDown() {
Main_clearAllPlayerEvents();
Main_addEventListener('keydown', PlayClip_handleKeyDown);
}

function Main_PlayHandleKeyDown() {
Main_clearAllPlayerEvents();
Main_addEventListener('keydown', Play_handleKeyDown);
}

function Main_clearAllPlayerEvents() {
Main_removeEventListener('keydown', Play_handleKeyDown);
Main_removeEventListener('keydown', PlayVod_handleKeyDown);
Main_removeEventListener('keydown', PlayClip_handleKeyDown);
Main_removeEventListener('keydown', ChatLiveControls_handleKeyDown);
Main_removeEventListener('keydown', ChatLiveControls_KeyboardEvent);
Main_removeEventListener('keydown', ChatLiveControls_EmotesEvent);
Main_removeEventListener('keydown', ChatLiveControls_ChooseChat);
Main_removeEventListener('keydown', ChatLiveControls_OptionsKeyDown);

Main_removeEventListener('keydown', Play_EndUpclearCalback);

Main_removeEventListener('keyup', PlayVod_SeekClear);
Main_removeEventListener('keyup', Play_handleKeyUp);
}

function Main_removeFocus(id, idArray) {
Screens_LoadPreviewSTop();
Main_HideWarningDialog();
Expand Down Expand Up @@ -3180,10 +3211,7 @@ function Main_clearInterval(id) {

function Main_onNewIntentClearPlay() {
Play_ClearPlayer();
Main_removeEventListener('keydown', Play_handleKeyDown);
Main_removeEventListener('keydown', PlayVod_handleKeyDown);
Main_removeEventListener('keyup', PlayVod_SeekClear);
Main_removeEventListener('keydown', PlayClip_handleKeyDown);
Main_clearAllPlayerEvents();
Play_isOn = false;
PlayVod_isOn = false;
PlayClip_isOn = false;
Expand Down
3 changes: 1 addition & 2 deletions app/specific/Play.js
Original file line number Diff line number Diff line change
Expand Up @@ -2200,8 +2200,7 @@ function Play_RestorePlayDataValues() {

function Play_handleKeyUpClear() {
Main_clearTimeout(PlayExtra_KeyEnterID);
Main_removeEventListener('keyup', Play_handleKeyUp);
Main_addEventListener('keydown', Play_handleKeyDown);
Main_PlayHandleKeyDown();
}

function Play_Exit() {
Expand Down
10 changes: 8 additions & 2 deletions app/specific/PlayClip.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ function PlayClip_OpenVodEnd() {
Main_vodOffset = ChannelVod_vodOffset;
PlayClip_OpenAVodOffset = Main_vodOffset;
PlayClip_PreshutdownStream(true);
Main_addEventListener('keydown', PlayVod_handleKeyDown);
Main_PlayVodHandleKeyDown();
PlayClip_OpenAVod = true;
PlayVod_Start();
}
Expand Down Expand Up @@ -737,6 +737,12 @@ function PlayClip_CheckPreviewClip() {
}

function PlayClip_handleKeyDown(e) {
//console.log('PlayClip_handleKeyDown', e.keyCode);

if (!PlayClip_isOn || !Main_isScene2DocVisible()) {
return;
}

Play_screeOn();

switch (e.keyCode) {
Expand Down Expand Up @@ -808,7 +814,7 @@ function PlayClip_handleKeyDown(e) {
PlayClip_setHidePanel();
} else if (Play_isEndDialogVisible() || UserLiveFeed_isPreviewShowing()) {
Play_EndTextClear();
Main_removeEventListener('keydown', PlayClip_handleKeyDown);
Main_clearAllPlayerEvents();
Main_addEventListener('keyup', Play_handleKeyUp);
Play_EndUpclear = false;
Play_EndUpclearCalback = PlayClip_handleKeyDown;
Expand Down
14 changes: 10 additions & 4 deletions app/specific/PlayEtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ function Play_OpenHost() {
Play_data.data[1] = Play_TargetHost.displayName;
Play_PreshutdownStream(false);

Main_addEventListener('keydown', Play_handleKeyDown);
Main_PlayHandleKeyDown();

Play_data.data[14] = Play_TargetHost.id;

Expand Down Expand Up @@ -1710,6 +1710,12 @@ function Play_handleKeyUpEndClear() {
}

function Play_handleKeyDown(e) {
//console.log('Play_handleKeyDown', e.keyCode);

if (!Play_isOn || !Main_isScene2DocVisible()) {
return;
}

Play_screeOn();

switch (e.keyCode) {
Expand Down Expand Up @@ -1807,7 +1813,7 @@ function Play_handleKeyDown(e) {
} else if (!UserLiveFeed_isPreviewShowing()) UserLiveFeed_ShowFeed();
else if (Play_isEndDialogVisible() || UserLiveFeed_isPreviewShowing()) {
Play_EndTextClear();
Main_removeEventListener('keydown', Play_handleKeyDown);
Main_clearAllPlayerEvents();
Main_addEventListener('keyup', Play_handleKeyUp);
Play_EndUpclear = false;
Play_EndUpclearCalback = Play_handleKeyDown;
Expand Down Expand Up @@ -1836,7 +1842,7 @@ function Play_handleKeyDown(e) {
} else if (Play_isEndDialogVisible()) Play_EndDialogUpDown(1);
else if (UserLiveFeed_isPreviewShowing()) UserLiveFeed_KeyUpDown(1);
else if (PlayExtra_PicturePicture || Play_MultiEnable) {
Main_removeEventListener('keydown', Play_handleKeyDown);
Main_clearAllPlayerEvents();
Main_addEventListener('keyup', Play_handleKeyUp);
Play_EndUpclear = false;
Play_EndUpclearCalback = Play_handleKeyDown;
Expand Down Expand Up @@ -1888,7 +1894,7 @@ function Play_handleKeyDown(e) {
} else if (Play_StayDialogVisible()) {
Play_OpenLiveFeedCheck();
} else {
Main_removeEventListener('keydown', Play_handleKeyDown);
Main_clearAllPlayerEvents();
Main_addEventListener('keyup', Play_handleKeyUp);
PlayExtra_clear = false;
UserLiveFeed_ResetFeedId();
Expand Down
8 changes: 7 additions & 1 deletion app/specific/PlayVod.js
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,12 @@ function PlayVod_SetPreview() {
}

function PlayVod_handleKeyDown(e) {
//console.log('PlayVod_handleKeyDown', e.keyCode);

if (!PlayVod_isOn || !Main_isScene2DocVisible()) {
return;
}

Play_screeOn();

switch (e.keyCode) {
Expand Down Expand Up @@ -1240,7 +1246,7 @@ function PlayVod_handleKeyDown(e) {
PlayVod_setHidePanel();
} else if (Play_isEndDialogVisible() || UserLiveFeed_isPreviewShowing()) {
Play_EndTextClear();
Main_removeEventListener('keydown', PlayVod_handleKeyDown);
Main_clearAllPlayerEvents();
Main_addEventListener('keyup', Play_handleKeyUp);
Play_EndUpclear = false;
Play_EndUpclearCalback = PlayVod_handleKeyDown;
Expand Down

0 comments on commit b1fd6c9

Please sign in to comment.