This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eval :: Query ~> H.ComponentDSL FrontendState Query Message (Aff _) | |
-- Handle initialization | |
eval (Init next) = do | |
-- Initialize YouTube player | |
player <- liftAff $ YT.initPlayer "player" | |
-- Player's 'onReady' handler, here we should call updatePlayerState with the *current* state | |
(\p -> do | |
let (state :: FrontendState) = H.get -- This won't work as we're in Eff here... :( | |
launchAff_ $ updatePlayerState state p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a <- liftAff $ createA (\x -> -- would need 'a' here) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
player <- liftAff $ YT.initPlayer "player" | |
\foo -> -- would need player here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let (loadedVideo :: Maybe VideoId) = old.loadedVideoId | |
let (nextVideo :: Maybe VideoId) = _.id <$> head new.app.queue | |
liftEff $ | |
case new.app.play /\ nextVideo of | |
true /\ loadedVideo -> YT.callPlayer player "playVideo" [] | |
true /\ Just nextVideo' -> YT.callPlayer player "loadVideoById" [unwrap nextVideo'] | |
_ -> YT.callPlayer player "pauseVideo" [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type SearchResult = | |
{ videoId :: String | |
, title :: String | |
, channelTitle :: String | |
, thumbnail :: String | |
, description :: String | |
} | |
type SearchResults = Array SearchResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"etag": "\"RmznBCICv9YtgWaaa_nWDIH1_GM/XPwtaUVS1YHeaqOqM5QXLXM0-vU\"", | |
"items": [ | |
{ | |
"etag": "\"RmznBCICv9YtgWaaa_nWDIH1_GM/CcqOjx_q-jaK3Lst_gsR8L4tadQ\"", | |
"id": { | |
"kind": "youtube#video", | |
"videoId": "dQw4w9WgXcQ" | |
}, | |
"kind": "youtube#searchResult", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type PlayPauseMessage = | |
{ play :: Boolean } | |
type SkipMessage = | |
{ skip :: Int } | |
data Message | |
= PlayPause PlayPauseMessage | |
| Skip SkipMessage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handleMessage | |
:: forall e | |
. SockJS.Connection | |
-> Message | |
-> Eff (console :: CONSOLE | e) Unit | |
handleMessage conn (CurrentQueue message) = do | |
-- how to modify state here? | |
log $ "queue message: " <> unsafeStringify message | |
handleMessage conn (PlayPause message) = do | |
log $ "play/pause message: " <> unsafeStringify message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"queue":["dQw4w9WgXcQ","dNCrpIL2XlY","RYRLEzQVqTs","d01XRSB-7dA","MGFiqGGVAuk","whScLb0aAiM","2vjPBrBU-TM","M | |
NyG-xu-7SQ","_DV7Lfxdp_0","_DV7Lfxdp_0","tVj0ZTS4WF4","isP-mRUSJ6k","K0a_ofU-pLE","eW6sEkTGbUc","feA64wXhbjo", | |
"ntuZWHd-l_Y","Lo_edXUlrT8","Qi3KQ1FN_aE","Qi3KQ1FN_aE","dQw4w9WgXcQ","d01XRSB-7dA","koGrknEchhk","8ZCysBT5Kec | |
","koGrknEchhk","koGrknEchhk","fbGkxcY7YFU","fiU65nQdZE8","Ly9Uw3oaIwc","FMElp1zibWc","KJbi8AaAp0g","ZZ5LpwO-A | |
n4&list=RDQMDsgEFzZyzxs","vTIIMJ9tUc8","eDWuhjKO8nI","2UByXynZDUw","dHDWtJpvURU","lAIGb1lfpBw","6M6samPEMpM"," | |
CduA0TULnow","bTm1C1ip3tI","bTm1C1ip3tI","bTm1C1ip3tI","wE3sp-RQUe0","jdCyG8zxUF8","g8ZFLCG05o4","XUhVCoTsBaM" | |
,"9bZkp7q19f0","OTAn2M63wZI","FoR43uPoLrM","1jre6_FBBc0","IJNR2EpS0jw","8Wp9iNINHMc","ETfiUYij5UE","YCME_bIuF3 | |
k","MtN1YnoL46Q","NyPmhjRuPjA","F8Cg572dafQ","uK3MLlTL5Ko","otCpCn0l4Wo","kffacxfA7G4","ymNFyxvIdaM","BS-CnWB4 | |
g7M","FdDDiEkRbvQ","dP9Wp6QVbsk","3_NaaZEjCWY","EbGjxdyRdOI","RqLAfErhXvU","pCdry6OQNtw","UrlKiddMtJQ","NX6qZl | |
Qnb1M", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newtype Light = Light | |
{ color :: LightColor | |
, prevColor :: LightColor | |
--, transitionStart :: Instant | |
, transitionStart :: Milliseconds | |
, transitionTime :: Milliseconds | |
} | |
type Lights = Map LightId Light |