diff --git a/app/specific/ChannelContent.js b/app/specific/ChannelContent.js index f488e55a7..682dab5a1 100644 --- a/app/specific/ChannelContent.js +++ b/app/specific/ChannelContent.js @@ -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); diff --git a/app/specific/ChatLiveControls.js b/app/specific/ChatLiveControls.js index d8b87f6c8..68af14230 100644 --- a/app/specific/ChatLiveControls.js +++ b/app/specific/ChatLiveControls.js @@ -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'); diff --git a/app/specific/Main.js b/app/specific/Main.js index 89c17edab..89b91f584 100644 --- a/app/specific/Main.js +++ b/app/specific/Main.js @@ -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(); @@ -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); @@ -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(); @@ -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; diff --git a/app/specific/Play.js b/app/specific/Play.js index ac845433e..fd25dfed5 100644 --- a/app/specific/Play.js +++ b/app/specific/Play.js @@ -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() { diff --git a/app/specific/PlayClip.js b/app/specific/PlayClip.js index ed32d38e0..e87e1bd87 100644 --- a/app/specific/PlayClip.js +++ b/app/specific/PlayClip.js @@ -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(); } @@ -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) { @@ -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; diff --git a/app/specific/PlayEtc.js b/app/specific/PlayEtc.js index 83cb39ed5..11263ca64 100644 --- a/app/specific/PlayEtc.js +++ b/app/specific/PlayEtc.js @@ -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; @@ -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) { @@ -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; @@ -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; @@ -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(); diff --git a/app/specific/PlayVod.js b/app/specific/PlayVod.js index 12e996837..7452f4c46 100644 --- a/app/specific/PlayVod.js +++ b/app/specific/PlayVod.js @@ -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) { @@ -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;