index.vue 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583
  1. <script setup lang="ts">
  2. import {
  3. defineAsyncComponent,
  4. ref,
  5. computed,
  6. watch,
  7. onMounted,
  8. onBeforeUnmount
  9. } from "vue";
  10. import { useRoute, useRouter } from "vue-router";
  11. import Toast from "toasters";
  12. import { storeToRefs } from "pinia";
  13. import { ContentLoader } from "vue-content-loader";
  14. import canAutoPlay from "can-autoplay";
  15. import { useSoundcloudPlayer } from "@/composables/useSoundcloudPlayer";
  16. import { useWebsocketsStore } from "@/stores/websockets";
  17. import { useStationStore } from "@/stores/station";
  18. import { useUserAuthStore } from "@/stores/userAuth";
  19. import { useUserPreferencesStore } from "@/stores/userPreferences";
  20. import { useModalsStore } from "@/stores/modals";
  21. import aw from "@/aw";
  22. import ms from "@/ms";
  23. import keyboardShortcuts from "@/keyboardShortcuts";
  24. import utils from "@/utils";
  25. const MainHeader = defineAsyncComponent(
  26. () => import("@/components/MainHeader.vue")
  27. );
  28. const MainFooter = defineAsyncComponent(
  29. () => import("@/components/MainFooter.vue")
  30. );
  31. const FloatingBox = defineAsyncComponent(
  32. () => import("@/components/FloatingBox.vue")
  33. );
  34. const StationInfoBox = defineAsyncComponent(
  35. () => import("@/components/StationInfoBox.vue")
  36. );
  37. const AddToPlaylistDropdown = defineAsyncComponent(
  38. () => import("@/components/AddToPlaylistDropdown.vue")
  39. );
  40. const SongItem = defineAsyncComponent(
  41. () => import("@/components/SongItem.vue")
  42. );
  43. const Z404 = defineAsyncComponent(() => import("@/pages/404.vue"));
  44. const StationSidebar = defineAsyncComponent(
  45. () => import("./Sidebar/index.vue")
  46. );
  47. const route = useRoute();
  48. const router = useRouter();
  49. const { socket } = useWebsocketsStore();
  50. const stationStore = useStationStore();
  51. const userAuthStore = useUserAuthStore();
  52. const userPreferencesStore = useUserPreferencesStore();
  53. const {
  54. soundcloudIframeElement,
  55. soundcloudLoadTrack,
  56. soundcloudSeekTo,
  57. soundcloudPlay,
  58. soundcloudPause,
  59. soundcloudSetVolume,
  60. soundcloudGetPosition,
  61. soundcloudGetIsPaused,
  62. soundcloudBindListener,
  63. soundcloudDestroy,
  64. soundcloudUnload
  65. } = useSoundcloudPlayer();
  66. // TODO this might need a different place, like onMounted
  67. const isApple = ref(
  68. navigator.platform.match(/iPhone|iPod|iPad/) ||
  69. navigator.vendor === "Apple Computer, Inc."
  70. );
  71. const loading = ref(true);
  72. const exists = ref(true);
  73. const youtubePlayerReady = ref(false);
  74. const youtubePlayer = ref(undefined);
  75. const timePaused = ref(0);
  76. const muted = ref(false);
  77. const timeElapsed = ref("0:00");
  78. const timeBeforePause = ref(0);
  79. const systemDifference = ref(0);
  80. const attemptsToPlayVideo = ref(0);
  81. const canAutoplay = ref(true);
  82. const lastTimeRequestedIfCanAutoplay = ref(0);
  83. const seeking = ref(false);
  84. const playbackRate = ref(1);
  85. const volumeSliderValue = ref(0);
  86. const showPlaylistDropdown = ref(false);
  87. const seekerbarPercentage = ref(0);
  88. const frontendDevMode = ref("production");
  89. const activityWatchVideoDataInterval = ref(null);
  90. const activityWatchVideoLastStatus = ref("");
  91. const activityWatchVideoLastYouTubeId = ref("");
  92. const activityWatchVideoLastStartDuration = ref(0);
  93. const reportStationStateInterval = ref(null);
  94. const nextCurrentSong = ref(null);
  95. const mediaModalWatcher = ref(null);
  96. const beforeMediaModalLocalPausedLock = ref(false);
  97. const beforeMediaModalLocalPaused = ref(null);
  98. const persistentToastCheckerInterval = ref(null);
  99. const persistentToasts = ref([]);
  100. const christmas = ref(false);
  101. const sitename = ref("Musare");
  102. // Experimental options
  103. const experimentalChangableListenModeEnabled = ref(false);
  104. const experimentalChangableListenMode = ref("listen_and_participate"); // Can be either listen_and_participate or participate
  105. const experimentalMediaSession = ref(false);
  106. // End experimental options
  107. // NEW
  108. const videoLoading = ref();
  109. const startedAt = ref();
  110. const pausedAt = ref();
  111. const stationIdentifier = ref();
  112. // ENDNEW
  113. const playerDebugBox = ref();
  114. const keyboardShortcutsHelper = ref();
  115. const modalsStore = useModalsStore();
  116. const { activeModals } = storeToRefs(modalsStore);
  117. // TODO fix this if it still has some use, as this is no longer accurate
  118. // const video = computed(() => store.state.modals.editSong);
  119. const { loggedIn, userId } = storeToRefs(userAuthStore);
  120. const { nightmode, autoSkipDisliked } = storeToRefs(userPreferencesStore);
  121. const {
  122. station,
  123. currentSong,
  124. nextSong,
  125. songsList,
  126. stationPaused,
  127. localPaused,
  128. noSong,
  129. autoRequest,
  130. autoRequestLock,
  131. history
  132. } = storeToRefs(stationStore);
  133. const youtubePlayerState = ref<
  134. null | "UNSTARTED" | "ENDED" | "PLAYING" | "PAUSED" | "BUFFERING" | "CUED"
  135. >(null);
  136. const skipVotesLoaded = computed(
  137. () =>
  138. !noSong.value &&
  139. Number.isInteger(currentSong.value.skipVotes) &&
  140. currentSong.value.skipVotes >= 0
  141. );
  142. const ratingsLoaded = computed(
  143. () =>
  144. !noSong.value &&
  145. Number.isInteger(currentSong.value.likes) &&
  146. Number.isInteger(currentSong.value.dislikes) &&
  147. currentSong.value.likes >= 0 &&
  148. currentSong.value.dislikes >= 0
  149. );
  150. const ownRatingsLoaded = computed(
  151. () =>
  152. !noSong.value &&
  153. typeof currentSong.value.liked === "boolean" &&
  154. typeof currentSong.value.disliked === "boolean"
  155. );
  156. const aModalIsOpen = computed(() => Object.keys(activeModals.value).length > 0);
  157. const currentUserQueueSongs = computed(
  158. () =>
  159. songsList.value.filter(
  160. queueSong => queueSong.requestedBy === userId.value
  161. ).length
  162. );
  163. const stationState = computed(() => {
  164. if (noSong.value) return "no_song";
  165. if (stationPaused.value) return "station_paused";
  166. if (
  167. experimentalChangableListenModeEnabled.value &&
  168. experimentalChangableListenMode.value === "participate"
  169. )
  170. return "participate";
  171. if (localPaused.value) return "local_paused";
  172. if (volumeSliderValue.value === 0 || muted.value) return "muted";
  173. if (youtubePlayerReady.value && youtubePlayerState.value === "PLAYING")
  174. return "playing";
  175. if (youtubePlayerReady.value && youtubePlayerState.value === "BUFFERING")
  176. return "buffering";
  177. return "unknown";
  178. });
  179. const currentSongMediaType = computed(() => {
  180. if (
  181. !currentSong.value ||
  182. !currentSong.value.mediaSource ||
  183. currentSong.value.mediaSource.indexOf(":") === -1
  184. )
  185. return "none";
  186. return currentSong.value.mediaSource.split(":")[0];
  187. });
  188. const currentSongMediaValue = computed(() => {
  189. if (
  190. !currentSong.value ||
  191. !currentSong.value.mediaSource ||
  192. currentSong.value.mediaSource.indexOf(":") === -1
  193. )
  194. return null;
  195. return currentSong.value.mediaSource.split(":")[1];
  196. });
  197. const currentYoutubeId = computed(() => {
  198. if (
  199. !currentSong.value ||
  200. !currentSong.value.mediaSource.startsWith("youtube:")
  201. )
  202. return null;
  203. return currentSong.value.mediaSource.split(":")[1];
  204. });
  205. const currentSongIsYoutube = computed(() => {
  206. if (
  207. !currentSong.value ||
  208. !currentSong.value.mediaSource.startsWith("youtube:")
  209. )
  210. return false;
  211. return true;
  212. });
  213. const {
  214. joinStation,
  215. leaveStation,
  216. updateStation,
  217. updateUserCount,
  218. updateUsers,
  219. updateCurrentSong,
  220. updateNextSong,
  221. updateSongsList,
  222. repositionSongInList,
  223. updateStationPaused,
  224. updateLocalPaused,
  225. updateNoSong,
  226. updateIfStationIsFavorited,
  227. setAutofillPlaylists,
  228. setBlacklist,
  229. updateCurrentSongRatings,
  230. updateOwnCurrentSongRatings,
  231. updateCurrentSongSkipVotes,
  232. updateAutoRequestLock,
  233. updateAutorequestLocalStorage,
  234. hasPermission,
  235. addDj,
  236. removeDj,
  237. updatePermissions,
  238. addHistoryItem,
  239. setHistory
  240. } = stationStore;
  241. // TODO fix this if it still has some use
  242. // const stopVideo = payload =>
  243. // store.dispatch("modals/editSong/stopVideo", payload);
  244. const recentlyPlayedYoutubeIds = (max: number) => {
  245. const mediaSources = new Set();
  246. history.value.forEach((historyItem, index) => {
  247. if (index < max) mediaSources.add(historyItem.payload.song.mediaSource);
  248. });
  249. return Array.from(mediaSources);
  250. };
  251. const updateMediaSessionData = song => {
  252. if (song) {
  253. ms.setMediaSessionData(
  254. 0,
  255. !localPaused.value && !stationPaused.value, // This should be improved later
  256. song.title,
  257. song.artists ? song.artists.join(", ") : null,
  258. null,
  259. song.thumbnail ||
  260. `https://img.youtube.com/vi/${song.youtubeId}/mqdefault.jpg`
  261. );
  262. } else ms.removeMediaSessionData(0);
  263. };
  264. const autoRequestSong = () => {
  265. const {
  266. limit,
  267. allowAutorequest,
  268. autorequestLimit,
  269. autorequestDisallowRecentlyPlayedEnabled,
  270. autorequestDisallowRecentlyPlayedNumber
  271. } = station.value.requests;
  272. if (autoRequestLock.value) return;
  273. if (!allowAutorequest) return;
  274. if (autoRequest.value.length === 0) return;
  275. updateAutorequestLocalStorage();
  276. if (currentUserQueueSongs.value >= limit) return;
  277. if (currentUserQueueSongs.value >= autorequestLimit) return;
  278. if (songsList.value.length >= 50) return;
  279. let excludedYoutubeIds = [];
  280. if (autorequestDisallowRecentlyPlayedEnabled) {
  281. excludedYoutubeIds = recentlyPlayedYoutubeIds(
  282. autorequestDisallowRecentlyPlayedNumber
  283. );
  284. }
  285. if (songsList.value) {
  286. songsList.value.forEach(song => {
  287. excludedYoutubeIds.push(song.mediaSource);
  288. });
  289. }
  290. if (!noSong.value) {
  291. excludedYoutubeIds.push(currentSong.value.mediaSource);
  292. }
  293. const uniqueYoutubeIds = new Set();
  294. autoRequest.value.forEach(playlist => {
  295. playlist.songs.forEach(song => {
  296. if (excludedYoutubeIds.indexOf(song.mediaSource) === -1)
  297. uniqueYoutubeIds.add(song.mediaSource);
  298. });
  299. });
  300. if (uniqueYoutubeIds.size > 0) {
  301. const mediaSource = Array.from(uniqueYoutubeIds.values())[
  302. Math.floor(Math.random() * uniqueYoutubeIds.size)
  303. ];
  304. updateAutoRequestLock(true);
  305. socket.dispatch(
  306. "stations.addToQueue",
  307. station.value._id,
  308. mediaSource,
  309. "autorequest",
  310. data => {
  311. updateAutoRequestLock(false);
  312. if (data.status !== "success") {
  313. setTimeout(
  314. () => {
  315. autoRequestSong();
  316. },
  317. data.message === "That song is already in the queue."
  318. ? 5000
  319. : 1000
  320. );
  321. }
  322. }
  323. );
  324. }
  325. };
  326. const dateCurrently = () => new Date().getTime() + systemDifference.value;
  327. const getTimeElapsed = () => {
  328. if (currentSong.value) {
  329. let localTimePaused = timePaused.value;
  330. if (stationPaused.value)
  331. localTimePaused += dateCurrently() - pausedAt.value;
  332. return dateCurrently() - startedAt.value - localTimePaused;
  333. }
  334. return 0;
  335. };
  336. const getTimeRemaining = () => {
  337. if (currentSong.value) {
  338. return currentSong.value.duration * 1000 - getTimeElapsed();
  339. }
  340. return 0;
  341. };
  342. const getCurrentPlayerTime = () =>
  343. new Promise<number>((resolve, reject) => {
  344. if (
  345. currentSongMediaType.value === "youtube" &&
  346. youtubePlayerReady.value
  347. ) {
  348. resolve(
  349. Math.max(
  350. youtubePlayer.value.getCurrentTime() -
  351. currentSong.value.skipDuration,
  352. 0
  353. ) * 1000
  354. );
  355. return;
  356. }
  357. if (currentSongMediaType.value === "soundcloud") {
  358. soundcloudGetPosition(position => {
  359. resolve(
  360. Math.max(
  361. position / 1000 - currentSong.value.skipDuration,
  362. 0
  363. ) * 1000
  364. );
  365. });
  366. return;
  367. }
  368. reject(new Error("No player."));
  369. });
  370. const skipSong = () => {
  371. if (nextCurrentSong.value && nextCurrentSong.value.currentSong) {
  372. const _songsList = songsList.value.concat([]);
  373. if (
  374. _songsList.length > 0 &&
  375. _songsList[0].mediaSource ===
  376. nextCurrentSong.value.currentSong.mediaSource
  377. ) {
  378. _songsList.splice(0, 1);
  379. updateSongsList(_songsList);
  380. }
  381. // TODO fix
  382. // eslint-disable-next-line
  383. setCurrentSong(nextCurrentSong.value);
  384. } else {
  385. // TODO fix
  386. // eslint-disable-next-line
  387. setCurrentSong({
  388. currentSong: null,
  389. startedAt: 0,
  390. paused: stationPaused.value,
  391. timePaused: 0,
  392. pausedAt: 0
  393. });
  394. }
  395. };
  396. const setNextCurrentSong = (_nextCurrentSong, skipSkipCheck = false) => {
  397. nextCurrentSong.value = _nextCurrentSong;
  398. // If skipSkipCheck is true, it won't try to skip the song
  399. if (getTimeRemaining() <= 0 && !skipSkipCheck) {
  400. skipSong();
  401. }
  402. };
  403. const resizeSeekerbar = () => {
  404. seekerbarPercentage.value =
  405. (getTimeElapsed() / 1000 / currentSong.value.duration) * 100;
  406. };
  407. const calculateTimeElapsed = async () => {
  408. if (experimentalChangableListenMode.value === "participate") return;
  409. if (
  410. youtubePlayerReady.value &&
  411. currentSongMediaType.value === "youtube" &&
  412. !noSong.value &&
  413. currentSong.value &&
  414. youtubePlayer.value.getPlayerState() === -1
  415. ) {
  416. if (!canAutoplay.value) {
  417. if (Date.now() - lastTimeRequestedIfCanAutoplay.value > 2000) {
  418. lastTimeRequestedIfCanAutoplay.value = Date.now();
  419. canAutoPlay.video().then(({ result }) => {
  420. if (result) {
  421. attemptsToPlayVideo.value = 0;
  422. canAutoplay.value = true;
  423. } else {
  424. canAutoplay.value = false;
  425. }
  426. });
  427. }
  428. } else {
  429. youtubePlayer.value.playVideo();
  430. attemptsToPlayVideo.value += 1;
  431. }
  432. }
  433. if (!stationPaused.value && !localPaused.value && !isApple.value) {
  434. const timeElapsed = getTimeElapsed();
  435. const currentPlayerTime = await getCurrentPlayerTime();
  436. const difference = timeElapsed - currentPlayerTime;
  437. let _playbackRate = 1;
  438. if (difference < -2000) {
  439. if (!seeking.value) {
  440. seeking.value = true;
  441. playerSeekTo(
  442. getTimeElapsed() / 1000 + currentSong.value.skipDuration
  443. );
  444. }
  445. } else if (difference < -200) {
  446. _playbackRate = 0.8;
  447. } else if (difference < -50) {
  448. _playbackRate = 0.9;
  449. } else if (difference < -25) {
  450. _playbackRate = 0.95;
  451. } else if (difference > 2000) {
  452. if (!seeking.value) {
  453. seeking.value = true;
  454. playerSeekTo(
  455. getTimeElapsed() / 1000 + currentSong.value.skipDuration
  456. );
  457. }
  458. } else if (difference > 200) {
  459. _playbackRate = 1.2;
  460. } else if (difference > 50) {
  461. _playbackRate = 1.1;
  462. } else if (difference > 25) {
  463. _playbackRate = 1.05;
  464. } else if (
  465. currentSongMediaType.value === "youtube" &&
  466. youtubeReady.value &&
  467. youtubePlayer.value.getPlaybackRate !== 1.0
  468. ) {
  469. youtubePlayer.value.setPlaybackRate(1.0);
  470. }
  471. if (
  472. currentSongMediaType.value === "youtube" &&
  473. youtubeReady.value &&
  474. playbackRate.value !== _playbackRate
  475. ) {
  476. youtubePlayer.value.setPlaybackRate(_playbackRate);
  477. playbackRate.value = _playbackRate;
  478. }
  479. }
  480. let localTimePaused = timePaused.value;
  481. if (stationPaused.value)
  482. localTimePaused += dateCurrently() - pausedAt.value;
  483. const duration =
  484. (dateCurrently() - startedAt.value - localTimePaused) / 1000;
  485. const songDuration = currentSong.value.duration;
  486. if (youtubePlayerReady.value && songDuration <= duration) playerPause();
  487. if (duration <= songDuration)
  488. timeElapsed.value =
  489. typeof duration === "number" ? utils.formatTime(duration) : "0";
  490. };
  491. const playVideo = () => {
  492. if (currentSongMediaType.value === "youtube") {
  493. if (youtubePlayerReady.value) {
  494. videoLoading.value = true;
  495. youtubePlayer.value.loadVideoById(
  496. currentYoutubeId.value,
  497. getTimeElapsed() / 1000 + currentSong.value.skipDuration
  498. );
  499. }
  500. } else if (currentSongMediaType.value === "soundcloud") {
  501. const soundcloudId = currentSongMediaValue.value;
  502. soundcloudLoadTrack(
  503. soundcloudId,
  504. getTimeElapsed() / 1000 + currentSong.value.skipDuration,
  505. localPaused.value || stationPaused.value
  506. );
  507. }
  508. if (window.stationInterval !== 0) clearInterval(window.stationInterval);
  509. window.stationInterval = window.setInterval(() => {
  510. if (!stationPaused.value) {
  511. resizeSeekerbar();
  512. calculateTimeElapsed();
  513. }
  514. }, 150);
  515. };
  516. const changeSoundcloudPlayerVolume = () => {
  517. if (muted.value) soundcloudSetVolume(0);
  518. else soundcloudSetVolume(volumeSliderValue.value);
  519. };
  520. const changePlayerVolume = () => {
  521. if (youtubePlayerReady.value) {
  522. youtubePlayer.value.setVolume(volumeSliderValue.value);
  523. if (muted.value) youtubePlayer.value.mute();
  524. else youtubePlayer.value.unMute();
  525. }
  526. changeSoundcloudPlayerVolume();
  527. };
  528. const playerPlay = () => {
  529. if (currentSongMediaType.value === "youtube" && youtubePlayerReady.value) {
  530. youtubePlayer.value.playVideo();
  531. }
  532. if (currentSongMediaType.value === "soundcloud") {
  533. soundcloudPlay();
  534. }
  535. };
  536. const playerStop = () => {
  537. if (youtubePlayerReady.value) {
  538. youtubePlayer.value.stopVideo();
  539. }
  540. soundcloudPause();
  541. };
  542. const playerPause = () => {
  543. if (youtubePlayerReady.value) {
  544. youtubePlayer.value.pauseVideo();
  545. }
  546. soundcloudPause();
  547. };
  548. const playerSeekTo = position => {
  549. // Position is in seconds
  550. if (youtubePlayerReady.value) {
  551. youtubePlayer.value.seekTo(position * 1000);
  552. }
  553. if (currentSongMediaType.value === "soundcloud") {
  554. soundcloudSeekTo(position * 1000);
  555. }
  556. };
  557. const toggleSkipVote = (message?) => {
  558. socket.dispatch("stations.toggleSkipVote", station.value._id, data => {
  559. if (data.status !== "success") new Toast(`Error: ${data.message}`);
  560. else
  561. new Toast(
  562. message || "Successfully toggled vote to skip the current song."
  563. );
  564. });
  565. };
  566. const youtubeReady = () => {
  567. if (experimentalChangableListenMode.value === "participate") return;
  568. if (!youtubePlayer.value) {
  569. ms.setYTReady(false);
  570. youtubePlayer.value = new window.YT.Player("youtubeStationPlayer", {
  571. height: 270,
  572. width: 480,
  573. // TODO CHECK TYPE
  574. videoId: currentYoutubeId.value,
  575. host: "https://www.youtube-nocookie.com",
  576. startSeconds:
  577. getTimeElapsed() / 1000 + currentSong.value.skipDuration,
  578. playerVars: {
  579. controls: 0,
  580. iv_load_policy: 3,
  581. rel: 0,
  582. showinfo: 0,
  583. disablekb: 1,
  584. playsinline: 1
  585. },
  586. events: {
  587. onReady: () => {
  588. youtubePlayerReady.value = true;
  589. ms.setYTReady(true);
  590. changePlayerVolume();
  591. playVideo();
  592. const duration =
  593. (dateCurrently() - startedAt.value - timePaused.value) /
  594. 1000;
  595. const songDuration = currentSong.value.duration;
  596. if (songDuration <= duration)
  597. youtubePlayer.value.pauseVideo();
  598. // on ios, playback will be forcibly paused locally
  599. if (isApple.value) {
  600. updateLocalPaused(true);
  601. new Toast(
  602. `Please click play manually to use ${sitename.value} on iOS.`
  603. );
  604. }
  605. },
  606. onError: err => {
  607. console.log("error with youtube video", err);
  608. if (err.data === 150 && loggedIn.value) {
  609. if (
  610. !(localPaused.value || stationPaused.value) &&
  611. !currentSong.value.voted
  612. ) {
  613. // automatically vote to skip
  614. toggleSkipVote(
  615. "Automatically voted to skip as this song isn't available for you."
  616. );
  617. }
  618. // persistent message while song is playing
  619. const persistentToast = new Toast({
  620. content:
  621. "This song is unavailable for you, but is playing for everyone else.",
  622. persistent: true
  623. });
  624. // save current song id
  625. const erroredYoutubeId = currentSong.value.mediaSource;
  626. persistentToasts.value.push({
  627. toast: persistentToast,
  628. checkIfCanRemove: () => {
  629. if (
  630. currentSong.value.mediaSource ===
  631. erroredYoutubeId
  632. ) {
  633. persistentToast.destroy();
  634. return true;
  635. }
  636. return false;
  637. }
  638. });
  639. } else {
  640. new Toast(
  641. "There has been an error with the YouTube Embed"
  642. );
  643. }
  644. },
  645. onStateChange: event => {
  646. switch (event.data) {
  647. case window.YT.PlayerState.UNSTARTED:
  648. youtubePlayerState.value = "UNSTARTED";
  649. break;
  650. case window.YT.PlayerState.ENDED:
  651. youtubePlayerState.value = "ENDED";
  652. break;
  653. case window.YT.PlayerState.PLAYING:
  654. youtubePlayerState.value = "PLAYING";
  655. break;
  656. case window.YT.PlayerState.PAUSED:
  657. youtubePlayerState.value = "PAUSED";
  658. break;
  659. case window.YT.PlayerState.BUFFERING:
  660. youtubePlayerState.value = "BUFFERING";
  661. break;
  662. case window.YT.PlayerState.CUED:
  663. youtubePlayerState.value = "CUED";
  664. break;
  665. default:
  666. youtubePlayerState.value = null;
  667. }
  668. if (
  669. event.data === window.YT.PlayerState.PLAYING &&
  670. videoLoading.value === true
  671. ) {
  672. videoLoading.value = false;
  673. youtubePlayer.value.seekTo(
  674. getTimeElapsed() / 1000 +
  675. currentSong.value.skipDuration,
  676. true
  677. );
  678. canAutoplay.value = true;
  679. if (localPaused.value || stationPaused.value)
  680. youtubePlayer.value.pauseVideo();
  681. } else if (
  682. event.data === window.YT.PlayerState.PLAYING &&
  683. (localPaused.value || stationPaused.value)
  684. ) {
  685. youtubePlayer.value.seekTo(
  686. timeBeforePause.value / 1000,
  687. true
  688. );
  689. youtubePlayer.value.pauseVideo();
  690. } else if (
  691. event.data === window.YT.PlayerState.PLAYING &&
  692. seeking.value === true
  693. )
  694. seeking.value = false;
  695. if (
  696. event.data === window.YT.PlayerState.PAUSED &&
  697. !localPaused.value &&
  698. !stationPaused.value &&
  699. !noSong.value &&
  700. youtubePlayer.value.getDuration() / 1000 <
  701. currentSong.value.duration
  702. ) {
  703. youtubePlayer.value.seekTo(
  704. getTimeElapsed() / 1000 +
  705. currentSong.value.skipDuration,
  706. true
  707. );
  708. youtubePlayer.value.playVideo();
  709. }
  710. }
  711. }
  712. });
  713. }
  714. };
  715. const setCurrentSong = data => {
  716. const {
  717. currentSong: _currentSong,
  718. startedAt: _startedAt,
  719. paused: _paused,
  720. timePaused: _timePaused,
  721. pausedAt: _pausedAt
  722. } = data;
  723. if (_currentSong) {
  724. if (!_currentSong.skipDuration || _currentSong.skipDuration < 0)
  725. _currentSong.skipDuration = 0;
  726. if (!_currentSong.duration || _currentSong.duration < 0)
  727. _currentSong.duration = 0;
  728. }
  729. updateCurrentSong(_currentSong || {});
  730. let nextSong = null;
  731. if (songsList.value[0])
  732. nextSong = songsList.value[0].mediaSource ? songsList.value[0] : null;
  733. updateNextSong(nextSong);
  734. setNextCurrentSong(
  735. {
  736. currentSong: null,
  737. startedAt: 0,
  738. _paused,
  739. timePaused: 0,
  740. pausedAt: 0
  741. },
  742. true
  743. );
  744. clearTimeout(window.stationNextSongTimeout);
  745. if (experimentalMediaSession.value) updateMediaSessionData(_currentSong);
  746. startedAt.value = _startedAt;
  747. updateStationPaused(_paused);
  748. timePaused.value = _timePaused;
  749. pausedAt.value = _pausedAt;
  750. if (_currentSong) {
  751. updateNoSong(false);
  752. if (currentSongMediaType.value === "youtube") {
  753. if (!youtubePlayerReady.value) youtubeReady();
  754. else playVideo();
  755. } else if (currentSongMediaType.value === "soundcloud") {
  756. playVideo();
  757. }
  758. // If the station is playing and the backend is not connected, set the next song to skip to after this song and set a timer to skip
  759. if (!stationPaused.value && !socket.ready) {
  760. if (nextSong)
  761. setNextCurrentSong(
  762. {
  763. currentSong: nextSong,
  764. startedAt: Date.now() + getTimeRemaining(),
  765. paused: false,
  766. timePaused: 0
  767. },
  768. true
  769. );
  770. else
  771. setNextCurrentSong(
  772. {
  773. currentSong: null,
  774. startedAt: 0,
  775. paused: false,
  776. timePaused: 0,
  777. pausedAt: 0
  778. },
  779. true
  780. );
  781. window.stationNextSongTimeout = setTimeout(() => {
  782. if (
  783. !noSong.value &&
  784. _currentSong.value._id === _currentSong._id
  785. )
  786. skipSong();
  787. }, getTimeRemaining());
  788. }
  789. const currentSongId = currentSong.value._id;
  790. socket.dispatch(
  791. "stations.getSkipVotes",
  792. station.value._id,
  793. currentSongId,
  794. res => {
  795. if (res.status === "success") {
  796. const { skipVotes, skipVotesCurrent, voted } = res.data;
  797. if (
  798. !noSong.value &&
  799. currentSong.value._id === currentSongId
  800. ) {
  801. updateCurrentSongSkipVotes({
  802. skipVotes,
  803. skipVotesCurrent,
  804. voted
  805. });
  806. }
  807. }
  808. }
  809. );
  810. socket.dispatch("media.getRatings", _currentSong.mediaSource, res => {
  811. if (_currentSong.mediaSource === currentSong.value.mediaSource) {
  812. const { likes, dislikes } = res.data;
  813. updateCurrentSongRatings({ likes, dislikes });
  814. }
  815. });
  816. if (loggedIn.value) {
  817. socket.dispatch(
  818. "media.getOwnRatings",
  819. _currentSong.mediaSource,
  820. res => {
  821. console.log("getOwnSongRatings", res);
  822. if (
  823. res.status === "success" &&
  824. currentSong.value.mediaSource === res.data.mediaSource
  825. ) {
  826. updateOwnCurrentSongRatings(res.data);
  827. if (
  828. autoSkipDisliked.value &&
  829. res.data.disliked === true &&
  830. !(localPaused.value || stationPaused.value) &&
  831. !currentSong.value.voted
  832. ) {
  833. toggleSkipVote(
  834. "Automatically voted to skip disliked song."
  835. );
  836. }
  837. }
  838. }
  839. );
  840. }
  841. } else {
  842. playerStop();
  843. updateNoSong(true);
  844. }
  845. calculateTimeElapsed();
  846. resizeSeekerbar();
  847. };
  848. const changeVolume = () => {
  849. const volume = volumeSliderValue.value;
  850. localStorage.setItem("volume", `${volume}`);
  851. muted.value = volume <= 0;
  852. localStorage.setItem("muted", `${muted.value}`);
  853. changePlayerVolume();
  854. };
  855. const resumeLocalPlayer = () => {
  856. if (experimentalMediaSession.value)
  857. updateMediaSessionData(currentSong.value);
  858. if (!noSong.value) {
  859. playerSeekTo(getTimeElapsed() / 1000 + currentSong.value.skipDuration);
  860. playerPlay();
  861. }
  862. };
  863. const pauseLocalPlayer = () => {
  864. if (experimentalMediaSession.value)
  865. updateMediaSessionData(currentSong.value);
  866. if (!noSong.value) {
  867. timeBeforePause.value = getTimeElapsed();
  868. playerPause();
  869. }
  870. };
  871. const resumeLocalStation = () => {
  872. updateLocalPaused(false);
  873. if (!stationPaused.value) resumeLocalPlayer();
  874. };
  875. const pauseLocalStation = () => {
  876. updateLocalPaused(true);
  877. pauseLocalPlayer();
  878. };
  879. const skipStation = () => {
  880. socket.dispatch("stations.forceSkip", station.value._id, data => {
  881. if (data.status !== "success") new Toast(`Error: ${data.message}`);
  882. else new Toast("Successfully skipped the station's current song.");
  883. });
  884. };
  885. const resumeStation = () => {
  886. socket.dispatch("stations.resume", station.value._id, data => {
  887. if (data.status !== "success") new Toast(`Error: ${data.message}`);
  888. else new Toast("Successfully resumed the station.");
  889. });
  890. };
  891. const pauseStation = () => {
  892. socket.dispatch("stations.pause", station.value._id, data => {
  893. if (data.status !== "success") new Toast(`Error: ${data.message}`);
  894. else new Toast("Successfully paused the station.");
  895. });
  896. };
  897. const toggleMute = () => {
  898. muted.value = !muted.value;
  899. changePlayerVolume();
  900. };
  901. const increaseVolume = () => {
  902. const previousVolume = parseFloat(localStorage.getItem("volume"));
  903. let volume = previousVolume + 5;
  904. if (previousVolume === 0) {
  905. muted.value = false;
  906. localStorage.setItem("muted", "false");
  907. }
  908. if (volume > 100) volume = 100;
  909. volumeSliderValue.value = volume;
  910. localStorage.setItem("volume", `${volume}`);
  911. changePlayerVolume();
  912. };
  913. const toggleLike = () => {
  914. if (currentSong.value.liked)
  915. socket.dispatch("media.unlike", currentSong.value.mediaSource, res => {
  916. if (res.status !== "success") new Toast(`Error: ${res.message}`);
  917. });
  918. else
  919. socket.dispatch("media.like", currentSong.value.mediaSource, res => {
  920. if (res.status !== "success") new Toast(`Error: ${res.message}`);
  921. });
  922. };
  923. const toggleDislike = () => {
  924. if (currentSong.value.disliked)
  925. return socket.dispatch(
  926. "media.undislike",
  927. currentSong.value.mediaSource,
  928. res => {
  929. if (res.status !== "success")
  930. new Toast(`Error: ${res.message}`);
  931. }
  932. );
  933. return socket.dispatch(
  934. "media.dislike",
  935. currentSong.value.mediaSource,
  936. res => {
  937. if (res.status !== "success") new Toast(`Error: ${res.message}`);
  938. }
  939. );
  940. };
  941. const togglePlayerDebugBox = () => {
  942. playerDebugBox.value.toggleBox();
  943. };
  944. const resetPlayerDebugBox = () => {
  945. playerDebugBox.value.resetBox();
  946. };
  947. const toggleKeyboardShortcutsHelper = () => {
  948. keyboardShortcutsHelper.value.toggleBox();
  949. };
  950. const resetKeyboardShortcutsHelper = () => {
  951. keyboardShortcutsHelper.value.resetBox();
  952. };
  953. const sendActivityWatchVideoData = () => {
  954. if (
  955. currentSongMediaType.value === "youtube" &&
  956. !stationPaused.value &&
  957. (!localPaused.value ||
  958. experimentalChangableListenMode.value === "participate") &&
  959. !noSong.value &&
  960. (experimentalChangableListenMode.value === "participate" ||
  961. youtubePlayer.value.getPlayerState() ===
  962. window.YT.PlayerState.PLAYING)
  963. ) {
  964. if (activityWatchVideoLastStatus.value !== "playing") {
  965. activityWatchVideoLastStatus.value = "playing";
  966. activityWatchVideoLastStartDuration.value =
  967. currentSong.value.skipDuration + getTimeElapsed();
  968. }
  969. if (
  970. activityWatchVideoLastYouTubeId.value !==
  971. currentSong.value.mediaSource
  972. ) {
  973. activityWatchVideoLastYouTubeId.value =
  974. currentSong.value.mediaSource;
  975. activityWatchVideoLastStartDuration.value =
  976. currentSong.value.skipDuration + getTimeElapsed();
  977. }
  978. const videoData = {
  979. title: currentSong.value ? currentSong.value.title : null,
  980. artists:
  981. currentSong.value && currentSong.value.artists
  982. ? currentSong.value.artists.join(", ")
  983. : null,
  984. mediaSource: currentSong.value.mediaSource,
  985. muted: muted.value,
  986. volume: volumeSliderValue.value,
  987. startedDuration:
  988. activityWatchVideoLastStartDuration.value <= 0
  989. ? 0
  990. : Math.floor(
  991. activityWatchVideoLastStartDuration.value / 1000
  992. ),
  993. source: `station#${station.value.name}`,
  994. hostname: window.location.hostname,
  995. playerState:
  996. experimentalChangableListenMode.value === "participate"
  997. ? "none"
  998. : Object.keys(window.YT.PlayerState).find(
  999. key =>
  1000. window.YT.PlayerState[key] ===
  1001. youtubePlayer.value.getPlayerState()
  1002. ),
  1003. playbackRate: playbackRate.value,
  1004. experimentalChangableListenMode:
  1005. experimentalChangableListenMode.value
  1006. };
  1007. aw.sendVideoData(videoData);
  1008. } else {
  1009. activityWatchVideoLastStatus.value = "not_playing";
  1010. }
  1011. };
  1012. const experimentalChangableListenModeChange = newMode => {
  1013. experimentalChangableListenMode.value = newMode;
  1014. localStorage.setItem(
  1015. `experimental_changeable_listen_mode_${station.value._id}`,
  1016. newMode
  1017. );
  1018. if (newMode === "participate") {
  1019. // Destroy the YouTube player
  1020. if (youtubePlayer.value) {
  1021. youtubePlayer.value.destroy();
  1022. youtubePlayer.value = null;
  1023. youtubePlayerReady.value = false;
  1024. youtubePlayerState.value = null;
  1025. }
  1026. soundcloudDestroy();
  1027. } else {
  1028. // Recreate the YouTube player
  1029. youtubeReady();
  1030. }
  1031. };
  1032. watch(
  1033. () => autoRequest.value.length,
  1034. () => {
  1035. autoRequestSong();
  1036. }
  1037. );
  1038. onMounted(async () => {
  1039. mediaModalWatcher.value = stationStore.$onAction(({ name, args }) => {
  1040. if (name === "updateMediaModalPlayingAudio") {
  1041. const [mediaModalPlayingAudio] = args;
  1042. if (mediaModalPlayingAudio) {
  1043. if (!beforeMediaModalLocalPausedLock.value) {
  1044. beforeMediaModalLocalPausedLock.value = true;
  1045. beforeMediaModalLocalPaused.value = localPaused.value;
  1046. pauseLocalStation();
  1047. }
  1048. } else {
  1049. beforeMediaModalLocalPausedLock.value = false;
  1050. if (!beforeMediaModalLocalPaused.value) resumeLocalStation();
  1051. }
  1052. }
  1053. });
  1054. document.body.scrollTo(0, 0);
  1055. stationIdentifier.value = route.params.id;
  1056. window.stationInterval = 0;
  1057. activityWatchVideoDataInterval.value = setInterval(() => {
  1058. sendActivityWatchVideoData();
  1059. }, 1000);
  1060. reportStationStateInterval.value = setInterval(() => {
  1061. socket.dispatch(
  1062. "stations.setStationState",
  1063. stationState.value,
  1064. () => {}
  1065. );
  1066. }, 5000);
  1067. persistentToastCheckerInterval.value = setInterval(() => {
  1068. persistentToasts.value.filter(
  1069. persistentToast => !persistentToast.checkIfCanRemove()
  1070. );
  1071. }, 1000);
  1072. const experimental = await lofig.get("experimental");
  1073. socket.onConnect(() => {
  1074. clearTimeout(window.stationNextSongTimeout);
  1075. socket.dispatch("stations.join", stationIdentifier.value, async res => {
  1076. if (res.status === "success") {
  1077. setTimeout(() => {
  1078. loading.value = false;
  1079. }, 1000); // prevents popping in of youtube embed etc.
  1080. const {
  1081. _id,
  1082. displayName,
  1083. name,
  1084. description,
  1085. privacy,
  1086. owner,
  1087. autofill,
  1088. blacklist,
  1089. type,
  1090. isFavorited,
  1091. theme,
  1092. requests,
  1093. djs
  1094. } = res.data;
  1095. if (experimental && experimental.changable_listen_mode) {
  1096. if (experimental.changable_listen_mode === true)
  1097. experimentalChangableListenModeEnabled.value = true;
  1098. else if (
  1099. Array.isArray(experimental.changable_listen_mode) &&
  1100. experimental.changable_listen_mode.indexOf(_id) !== -1
  1101. )
  1102. experimentalChangableListenModeEnabled.value = true;
  1103. }
  1104. if (experimentalChangableListenModeEnabled.value) {
  1105. console.log(
  1106. `Experimental changeable listen mode is enabled`
  1107. );
  1108. const experimentalChangeableListenModeLS =
  1109. localStorage.getItem(
  1110. `experimental_changeable_listen_mode_${_id}`
  1111. );
  1112. if (experimentalChangeableListenModeLS)
  1113. experimentalChangableListenMode.value =
  1114. experimentalChangeableListenModeLS;
  1115. }
  1116. // change url to use station name instead of station id
  1117. if (name !== stationIdentifier.value) {
  1118. // eslint-disable-next-line no-restricted-globals
  1119. router.replace(name);
  1120. }
  1121. joinStation({
  1122. _id,
  1123. name,
  1124. displayName,
  1125. description,
  1126. privacy,
  1127. owner,
  1128. autofill,
  1129. blacklist,
  1130. type,
  1131. isFavorited,
  1132. theme,
  1133. requests,
  1134. djs
  1135. });
  1136. document.getElementsByTagName(
  1137. "html"
  1138. )[0].style.cssText = `--primary-color: var(--${res.data.theme})`;
  1139. setCurrentSong({
  1140. currentSong: res.data.currentSong,
  1141. startedAt: res.data.startedAt,
  1142. paused: res.data.paused,
  1143. timePaused: res.data.timePaused,
  1144. pausedAt: res.data.pausedAt
  1145. });
  1146. updateUserCount(res.data.userCount);
  1147. updateUsers(res.data.users);
  1148. await updatePermissions();
  1149. socket.dispatch(
  1150. "stations.getStationAutofillPlaylistsById",
  1151. station.value._id,
  1152. res => {
  1153. if (res.status === "success") {
  1154. setAutofillPlaylists(res.data.playlists);
  1155. }
  1156. }
  1157. );
  1158. socket.dispatch(
  1159. "stations.getStationBlacklistById",
  1160. station.value._id,
  1161. res => {
  1162. if (res.status === "success") {
  1163. setBlacklist(res.data.playlists);
  1164. }
  1165. }
  1166. );
  1167. socket.dispatch("stations.getQueue", _id, res => {
  1168. if (res.status === "success") {
  1169. const { queue } = res.data;
  1170. updateSongsList(queue);
  1171. const [nextSong] = queue;
  1172. updateNextSong(nextSong);
  1173. }
  1174. });
  1175. socket.dispatch("stations.getHistory", _id, res => {
  1176. if (res.status === "success") {
  1177. const { history } = res.data;
  1178. setHistory(history);
  1179. }
  1180. });
  1181. if (hasPermission("stations.playback.toggle"))
  1182. keyboardShortcuts.registerShortcut("station.pauseResume", {
  1183. keyCode: 32, // Spacebar
  1184. shift: false,
  1185. ctrl: true,
  1186. preventDefault: true,
  1187. handler: () => {
  1188. if (aModalIsOpen.value) return;
  1189. if (stationPaused.value) resumeStation();
  1190. else pauseStation();
  1191. }
  1192. });
  1193. if (hasPermission("stations.skip"))
  1194. keyboardShortcuts.registerShortcut("station.skipStation", {
  1195. keyCode: 39, // Right arrow key
  1196. shift: false,
  1197. ctrl: true,
  1198. preventDefault: true,
  1199. handler: () => {
  1200. if (aModalIsOpen.value) return;
  1201. skipStation();
  1202. }
  1203. });
  1204. keyboardShortcuts.registerShortcut("station.lowerVolumeLarge", {
  1205. keyCode: 40, // Down arrow key
  1206. shift: false,
  1207. ctrl: true,
  1208. preventDefault: true,
  1209. handler: () => {
  1210. if (aModalIsOpen.value) return;
  1211. volumeSliderValue.value -= 10;
  1212. changeVolume();
  1213. }
  1214. });
  1215. keyboardShortcuts.registerShortcut("station.lowerVolumeSmall", {
  1216. keyCode: 40, // Down arrow key
  1217. shift: true,
  1218. ctrl: true,
  1219. preventDefault: true,
  1220. handler: () => {
  1221. if (aModalIsOpen.value) return;
  1222. volumeSliderValue.value -= 1;
  1223. changeVolume();
  1224. }
  1225. });
  1226. keyboardShortcuts.registerShortcut(
  1227. "station.increaseVolumeLarge",
  1228. {
  1229. keyCode: 38, // Up arrow key
  1230. shift: false,
  1231. ctrl: true,
  1232. preventDefault: true,
  1233. handler: () => {
  1234. if (aModalIsOpen.value) return;
  1235. volumeSliderValue.value += 10;
  1236. changeVolume();
  1237. }
  1238. }
  1239. );
  1240. keyboardShortcuts.registerShortcut(
  1241. "station.increaseVolumeSmall",
  1242. {
  1243. keyCode: 38, // Up arrow key
  1244. shift: true,
  1245. ctrl: true,
  1246. preventDefault: true,
  1247. handler: () => {
  1248. if (aModalIsOpen.value) return;
  1249. volumeSliderValue.value += 1;
  1250. changeVolume();
  1251. }
  1252. }
  1253. );
  1254. keyboardShortcuts.registerShortcut("station.toggleDebug", {
  1255. keyCode: 68, // D key
  1256. shift: false,
  1257. ctrl: true,
  1258. preventDefault: true,
  1259. handler: () => {
  1260. if (aModalIsOpen.value) return;
  1261. togglePlayerDebugBox();
  1262. }
  1263. });
  1264. keyboardShortcuts.registerShortcut(
  1265. "station.toggleKeyboardShortcutsHelper",
  1266. {
  1267. keyCode: 191, // '/' key
  1268. ctrl: true,
  1269. preventDefault: true,
  1270. handler: () => {
  1271. if (aModalIsOpen.value) return;
  1272. toggleKeyboardShortcutsHelper();
  1273. }
  1274. }
  1275. );
  1276. keyboardShortcuts.registerShortcut(
  1277. "station.resetKeyboardShortcutsHelper",
  1278. {
  1279. keyCode: 191, // '/' key
  1280. ctrl: true,
  1281. shift: true,
  1282. preventDefault: true,
  1283. handler: () => {
  1284. if (aModalIsOpen.value) return;
  1285. resetKeyboardShortcutsHelper();
  1286. }
  1287. }
  1288. );
  1289. // UNIX client time before ping
  1290. const beforePing = Date.now();
  1291. socket.dispatch("apis.ping", res => {
  1292. if (res.status === "success") {
  1293. // UNIX client time after ping
  1294. const afterPing = Date.now();
  1295. // Average time in MS it took between the server responding and the client receiving
  1296. const connectionLatency = (afterPing - beforePing) / 2;
  1297. console.log(connectionLatency, beforePing - afterPing);
  1298. // UNIX server time
  1299. const serverDate = res.data.date;
  1300. // Difference between the server UNIX time and the client UNIX time after ping, with the connectionLatency added to the server UNIX time
  1301. const difference =
  1302. serverDate + connectionLatency - afterPing;
  1303. console.log("Difference: ", difference);
  1304. if (difference > 3000 || difference < -3000) {
  1305. console.log(
  1306. "System time difference is bigger than 3 seconds."
  1307. );
  1308. }
  1309. systemDifference.value = difference;
  1310. }
  1311. });
  1312. } else {
  1313. loading.value = false;
  1314. exists.value = false;
  1315. }
  1316. });
  1317. socket.dispatch(
  1318. "stations.existsByName",
  1319. stationIdentifier.value,
  1320. res => {
  1321. if (res.status === "error" || !res.data.exists) {
  1322. // station identifier may be using stationid instead
  1323. socket.dispatch(
  1324. "stations.existsById",
  1325. stationIdentifier.value,
  1326. res => {
  1327. if (res.status === "error" || !res.data.exists) {
  1328. loading.value = false;
  1329. exists.value = false;
  1330. }
  1331. }
  1332. );
  1333. }
  1334. }
  1335. );
  1336. });
  1337. socket.onDisconnect(() => {
  1338. const _currentSong = currentSong.value;
  1339. if (nextSong.value)
  1340. setNextCurrentSong(
  1341. {
  1342. currentSong: nextSong.value,
  1343. startedAt: Date.now() + getTimeRemaining(),
  1344. paused: false,
  1345. timePaused: 0
  1346. },
  1347. true
  1348. );
  1349. else
  1350. setNextCurrentSong(
  1351. {
  1352. currentSong: null,
  1353. startedAt: 0,
  1354. paused: false,
  1355. timePaused: 0,
  1356. pausedAt: 0
  1357. },
  1358. true
  1359. );
  1360. window.stationNextSongTimeout = setTimeout(() => {
  1361. if (!noSong.value && currentSong.value._id === _currentSong._id)
  1362. skipSong();
  1363. }, getTimeRemaining());
  1364. }, true);
  1365. socket.on("event:station.nextSong", res => {
  1366. const { currentSong, startedAt, paused, timePaused } = res.data;
  1367. setCurrentSong({
  1368. currentSong,
  1369. startedAt,
  1370. paused,
  1371. timePaused,
  1372. pausedAt: 0
  1373. });
  1374. });
  1375. socket.on("event:station.pause", res => {
  1376. pausedAt.value = res.data.pausedAt;
  1377. updateStationPaused(true);
  1378. pauseLocalPlayer();
  1379. clearTimeout(window.stationNextSongTimeout);
  1380. });
  1381. socket.on("event:station.resume", res => {
  1382. timePaused.value = res.data.timePaused;
  1383. updateStationPaused(false);
  1384. if (!localPaused.value) resumeLocalPlayer();
  1385. autoRequestSong();
  1386. });
  1387. socket.on("event:station.deleted", () => {
  1388. router.push({
  1389. path: "/",
  1390. query: {
  1391. toast: "The station you were in was deleted."
  1392. }
  1393. });
  1394. });
  1395. socket.on("event:ratings.liked", res => {
  1396. if (!noSong.value) {
  1397. if (res.data.mediaSource === currentSong.value.mediaSource) {
  1398. updateCurrentSongRatings(res.data);
  1399. }
  1400. }
  1401. });
  1402. socket.on("event:ratings.disliked", res => {
  1403. if (!noSong.value) {
  1404. if (res.data.mediaSource === currentSong.value.mediaSource) {
  1405. updateCurrentSongRatings(res.data);
  1406. }
  1407. }
  1408. });
  1409. socket.on("event:ratings.unliked", res => {
  1410. if (!noSong.value) {
  1411. if (res.data.mediaSource === currentSong.value.mediaSource) {
  1412. updateCurrentSongRatings(res.data);
  1413. }
  1414. }
  1415. });
  1416. socket.on("event:ratings.undisliked", res => {
  1417. if (!noSong.value) {
  1418. if (res.data.mediaSource === currentSong.value.mediaSource) {
  1419. updateCurrentSongRatings(res.data);
  1420. }
  1421. }
  1422. });
  1423. socket.on("event:ratings.updated", res => {
  1424. if (!noSong.value) {
  1425. if (res.data.mediaSource === currentSong.value.mediaSource) {
  1426. updateOwnCurrentSongRatings(res.data);
  1427. }
  1428. }
  1429. });
  1430. socket.on("event:station.queue.updated", res => {
  1431. updateSongsList(res.data.queue);
  1432. let nextSong = null;
  1433. if (songsList.value[0])
  1434. nextSong = songsList.value[0].mediaSource
  1435. ? songsList.value[0]
  1436. : null;
  1437. updateNextSong(nextSong);
  1438. autoRequestSong();
  1439. });
  1440. socket.on("event:station.queue.song.repositioned", res => {
  1441. repositionSongInList(res.data.song);
  1442. let nextSong = null;
  1443. if (songsList.value[0])
  1444. nextSong = songsList.value[0].mediaSource
  1445. ? songsList.value[0]
  1446. : null;
  1447. updateNextSong(nextSong);
  1448. });
  1449. socket.on("event:station.toggleSkipVote", res => {
  1450. if (currentSong.value)
  1451. updateCurrentSongSkipVotes({
  1452. skipVotes: res.data.voted
  1453. ? currentSong.value.skipVotes + 1
  1454. : currentSong.value.skipVotes - 1,
  1455. skipVotesCurrent: null,
  1456. voted:
  1457. res.data.userId === userId.value
  1458. ? res.data.voted
  1459. : currentSong.value.voted
  1460. });
  1461. });
  1462. socket.on("event:station.updated", async res => {
  1463. const { name, theme, privacy } = res.data.station;
  1464. if (!hasPermission("stations.view") && privacy === "private") {
  1465. router.push({
  1466. path: "/",
  1467. query: {
  1468. toast: "The station you were in was made private."
  1469. }
  1470. });
  1471. } else {
  1472. if (station.value.name !== name) {
  1473. await router.push(
  1474. `${name}?${Object.keys(route.query)
  1475. .map(
  1476. key =>
  1477. `${encodeURIComponent(
  1478. key
  1479. )}=${encodeURIComponent(
  1480. JSON.stringify(route.query[key])
  1481. )}`
  1482. )
  1483. .join("&")}`
  1484. );
  1485. // eslint-disable-next-line no-restricted-globals
  1486. history.replaceState({ ...history.state, ...{} }, null);
  1487. }
  1488. if (station.value.theme !== theme)
  1489. document.getElementsByTagName(
  1490. "html"
  1491. )[0].style.cssText = `--primary-color: var(--${theme})`;
  1492. updateStation(res.data.station);
  1493. }
  1494. });
  1495. socket.on("event:station.users.updated", res =>
  1496. updateUsers(res.data.users)
  1497. );
  1498. socket.on("event:station.userCount.updated", res =>
  1499. updateUserCount(res.data.userCount)
  1500. );
  1501. socket.on("event:user.station.favorited", res => {
  1502. if (res.data.stationId === station.value._id)
  1503. updateIfStationIsFavorited({ isFavorited: true });
  1504. });
  1505. socket.on("event:user.station.unfavorited", res => {
  1506. if (res.data.stationId === station.value._id)
  1507. updateIfStationIsFavorited({ isFavorited: false });
  1508. });
  1509. socket.on("event:station.djs.added", res => {
  1510. if (res.data.user._id === userId.value)
  1511. updatePermissions().then(() => {
  1512. if (
  1513. !hasPermission("stations.view") &&
  1514. station.value.privacy === "private"
  1515. )
  1516. router.push({
  1517. path: "/",
  1518. query: {
  1519. toast: "You no longer have access to the station you were in."
  1520. }
  1521. });
  1522. });
  1523. addDj(res.data.user);
  1524. });
  1525. socket.on("event:station.djs.removed", res => {
  1526. if (res.data.user._id === userId.value)
  1527. updatePermissions().then(() => {
  1528. if (
  1529. !hasPermission("stations.view") &&
  1530. station.value.privacy === "private"
  1531. )
  1532. router.push({
  1533. path: "/",
  1534. query: {
  1535. toast: "You no longer have access to the station you were in."
  1536. }
  1537. });
  1538. });
  1539. removeDj(res.data.user);
  1540. });
  1541. socket.on("event:station.history.new", res => {
  1542. addHistoryItem(res.data.historyItem);
  1543. });
  1544. socket.on("keep.event:user.role.updated", () => {
  1545. updatePermissions().then(() => {
  1546. if (
  1547. !hasPermission("stations.view") &&
  1548. station.value.privacy === "private"
  1549. )
  1550. router.push({
  1551. path: "/",
  1552. query: {
  1553. toast: "You no longer have access to the station you were in."
  1554. }
  1555. });
  1556. });
  1557. });
  1558. frontendDevMode.value = await lofig.get("mode");
  1559. christmas.value = await lofig.get("siteSettings.christmas");
  1560. sitename.value = await lofig.get("siteSettings.sitename");
  1561. lofig.get("experimental").then(experimental => {
  1562. if (
  1563. experimental &&
  1564. Object.hasOwn(experimental, "media_session") &&
  1565. experimental.media_session
  1566. )
  1567. experimentalMediaSession.value = true;
  1568. });
  1569. ms.setListeners(0, {
  1570. play: () => {
  1571. if (hasPermission("stations.playback.toggle")) resumeStation();
  1572. else resumeLocalStation();
  1573. },
  1574. pause: () => {
  1575. if (hasPermission("stations.playback.toggle")) pauseStation();
  1576. else pauseLocalStation();
  1577. },
  1578. nexttrack: () => {
  1579. if (hasPermission("stations.skip")) skipStation();
  1580. else if (!currentSong.value.voted) toggleSkipVote();
  1581. }
  1582. });
  1583. if (JSON.parse(localStorage.getItem("muted"))) {
  1584. muted.value = true;
  1585. volumeSliderValue.value = 0;
  1586. } else {
  1587. let volume = parseFloat(localStorage.getItem("volume"));
  1588. volume =
  1589. typeof volume === "number" && !Number.isNaN(volume) ? volume : 20;
  1590. localStorage.setItem("volume", `${volume}`);
  1591. volumeSliderValue.value = volume;
  1592. }
  1593. changePlayerVolume();
  1594. soundcloudBindListener("play", () => {
  1595. if (currentSongMediaType.value !== "soundcloud") {
  1596. soundcloudPause();
  1597. return;
  1598. }
  1599. console.log("PLAY BIND", localPaused.value, stationPaused.value);
  1600. if (localPaused.value || stationPaused.value) {
  1601. soundcloudSeekTo(
  1602. (getTimeElapsed() / 1000 + currentSong.value.skipDuration) *
  1603. 1000
  1604. );
  1605. soundcloudPause();
  1606. }
  1607. });
  1608. soundcloudBindListener("pause", () => {
  1609. if (currentSongMediaType.value !== "soundcloud") return;
  1610. console.log("PAUSE BIND", localPaused.value, stationPaused.value);
  1611. if (!localPaused.value && !stationPaused.value) {
  1612. // soundcloudSeekTo(
  1613. // (getTimeElapsed() / 1000 + currentSong.value.skipDuration) *
  1614. // 1000
  1615. // );
  1616. // soundcloudPlay();
  1617. // let called = false;
  1618. // soundcloudGetIsPaused(isPaused => {
  1619. // if (called) return;
  1620. // called = true;
  1621. // console.log(123, isPaused);
  1622. // if (isPaused) {
  1623. // setTimeout(soundcloudPlay, 500);
  1624. // }
  1625. // });
  1626. }
  1627. });
  1628. soundcloudBindListener("seek", () => {
  1629. if (seeking.value) seeking.value = false;
  1630. });
  1631. soundcloudBindListener("error", value => {
  1632. console.log("SOUNDCLOUD ERROR", value);
  1633. });
  1634. });
  1635. onBeforeUnmount(() => {
  1636. document.getElementsByTagName("html")[0].style.cssText = "";
  1637. if (experimentalMediaSession.value) {
  1638. ms.removeListeners(0);
  1639. ms.removeMediaSessionData(0);
  1640. }
  1641. /** Reset Songslist */
  1642. updateSongsList([]);
  1643. const shortcutNames = [
  1644. "station.pauseResume",
  1645. "station.skipStation",
  1646. "station.lowerVolumeLarge",
  1647. "station.lowerVolumeSmall",
  1648. "station.increaseVolumeLarge",
  1649. "station.increaseVolumeSmall",
  1650. "station.toggleDebug"
  1651. ];
  1652. shortcutNames.forEach(shortcutName => {
  1653. keyboardShortcuts.unregisterShortcut(shortcutName);
  1654. });
  1655. mediaModalWatcher.value(); // removes the watcher
  1656. clearInterval(activityWatchVideoDataInterval.value);
  1657. clearTimeout(window.stationNextSongTimeout);
  1658. clearTimeout(persistentToastCheckerInterval.value);
  1659. clearInterval(reportStationStateInterval.value);
  1660. persistentToasts.value.forEach(persistentToast => {
  1661. persistentToast.toast.destroy();
  1662. });
  1663. socket.dispatch("stations.leave", station.value._id, () => {});
  1664. const { allowAutorequest } = station.value.requests;
  1665. if (
  1666. !autoRequestLock.value &&
  1667. allowAutorequest &&
  1668. autoRequest.value.length > 0
  1669. )
  1670. updateAutorequestLocalStorage();
  1671. leaveStation();
  1672. soundcloudUnload();
  1673. // Delete the Pinia store that was created for this station, after all other cleanup tasks are performed
  1674. stationStore.$dispose();
  1675. });
  1676. </script>
  1677. <template>
  1678. <div>
  1679. <page-metadata
  1680. v-if="exists && !loading"
  1681. :title="`${station.displayName}`"
  1682. />
  1683. <page-metadata v-else-if="!exists && !loading" :title="`Not found`" />
  1684. <div id="page-loader-container" v-if="loading">
  1685. <content-loader
  1686. width="1920"
  1687. height="1080"
  1688. :primary-color="nightmode ? '#222' : '#fff'"
  1689. :secondary-color="nightmode ? '#444' : '#ddd'"
  1690. preserve-aspect-ratio="none"
  1691. id="page-loader-content"
  1692. >
  1693. <rect x="55" y="105" rx="5" ry="5" width="670" height="149" />
  1694. <rect x="55" y="283" rx="5" ry="5" width="670" height="640" />
  1695. <rect x="745" y="108" rx="5" ry="5" width="1120" height="672" />
  1696. <rect x="745" y="810" rx="5" ry="5" width="1120" height="110" />
  1697. </content-loader>
  1698. <content-loader
  1699. width="1920"
  1700. height="1080"
  1701. :primary-color="nightmode ? '#222' : '#fff'"
  1702. :secondary-color="nightmode ? '#444' : '#ddd'"
  1703. preserve-aspect-ratio="none"
  1704. id="page-loader-layout"
  1705. >
  1706. <rect x="0" y="0" rx="0" ry="0" width="1920" height="64" />
  1707. <rect x="0" y="980" rx="0" ry="0" width="1920" height="100" />
  1708. </content-loader>
  1709. </div>
  1710. <!-- More simplistic loading animation for mobile users -->
  1711. <div v-show="loading" id="mobile-progress-animation" />
  1712. <ul
  1713. v-if="
  1714. currentSong &&
  1715. (currentSong.mediaSource === 'l9PxOanFjxQ' ||
  1716. currentSong.mediaSource === 'xKVcVSYmesU' ||
  1717. currentSong.mediaSource === '60ItHLz5WEA' ||
  1718. currentSong.mediaSource === 'e6vkFbtSGm0')
  1719. "
  1720. class="bg-bubbles"
  1721. >
  1722. <li></li>
  1723. <li></li>
  1724. <li></li>
  1725. <li></li>
  1726. <li></li>
  1727. <li></li>
  1728. <li></li>
  1729. <li></li>
  1730. <li></li>
  1731. <li></li>
  1732. </ul>
  1733. <div v-show="!loading && exists">
  1734. <main-header />
  1735. <div id="station-outer-container">
  1736. <div
  1737. id="station-inner-container"
  1738. :class="{ 'nothing-here': noSong }"
  1739. >
  1740. <div id="station-left-column" class="column">
  1741. <!-- div with quadrant class -->
  1742. <div class="quadrant">
  1743. <station-info-box
  1744. :station="station"
  1745. :station-paused="stationPaused"
  1746. :show-manage-station="true"
  1747. />
  1748. </div>
  1749. <div id="sidebar-container" class="quadrant">
  1750. <station-sidebar />
  1751. </div>
  1752. </div>
  1753. <div id="station-right-column" class="column">
  1754. <div
  1755. class="experimental-listen-mode-container quadrant"
  1756. v-if="
  1757. experimentalChangableListenModeEnabled &&
  1758. !noSong
  1759. "
  1760. v-show="
  1761. experimentalChangableListenMode ===
  1762. 'participate'
  1763. "
  1764. >
  1765. <button
  1766. class="button is-primary"
  1767. @click="
  1768. experimentalChangableListenModeChange(
  1769. 'listen_and_participate'
  1770. )
  1771. "
  1772. >
  1773. <i class="material-icons icon-with-button"
  1774. >music_note</i
  1775. >
  1776. <span>Listen to music</span>
  1777. </button>
  1778. <button
  1779. v-if="!skipVotesLoaded"
  1780. class="button is-primary disabled"
  1781. content="Skip votes have not been loaded yet"
  1782. v-tippy
  1783. >
  1784. <i class="material-icons icon-with-button"
  1785. >skip_next</i
  1786. >
  1787. Vote to skip the current song
  1788. </button>
  1789. <button
  1790. v-else-if="loggedIn"
  1791. :class="[
  1792. 'button',
  1793. 'is-primary',
  1794. { voted: currentSong.voted }
  1795. ]"
  1796. @click="toggleSkipVote()"
  1797. :content="`${
  1798. currentSong.voted ? 'Remove vote' : 'Vote'
  1799. } to Skip Song`"
  1800. v-tippy
  1801. >
  1802. <i class="material-icons icon-with-button"
  1803. >skip_next</i
  1804. >
  1805. Vote to skip the current song -
  1806. {{ currentSong.skipVotes }} votes
  1807. </button>
  1808. <button
  1809. v-else
  1810. class="button is-primary disabled"
  1811. content="Log in to vote to skip songs"
  1812. v-tippy="{ theme: 'info' }"
  1813. >
  1814. <i class="material-icons icon-with-button"
  1815. >skip_next</i
  1816. >
  1817. Vote to skip the current song -
  1818. {{ currentSong.skipVotes }} votes
  1819. </button>
  1820. <div class="row">
  1821. <!-- Ratings -->
  1822. <div
  1823. class="ratings"
  1824. v-if="ratingsLoaded && ownRatingsLoaded"
  1825. :class="{
  1826. liked: currentSong.liked,
  1827. disliked: currentSong.disliked
  1828. }"
  1829. >
  1830. <!-- Like Song Button -->
  1831. <button
  1832. class="button is-success like-song"
  1833. @click="toggleLike()"
  1834. content="Like Song"
  1835. v-tippy
  1836. >
  1837. <i
  1838. class="material-icons icon-with-button"
  1839. :class="{
  1840. liked: currentSong.liked
  1841. }"
  1842. >thumb_up_alt</i
  1843. >{{ currentSong.likes }}
  1844. </button>
  1845. <!-- Dislike Song Button -->
  1846. <button
  1847. class="button is-danger dislike-song"
  1848. @click="toggleDislike()"
  1849. content="Dislike Song"
  1850. v-tippy
  1851. >
  1852. <i
  1853. class="material-icons icon-with-button"
  1854. :class="{
  1855. disliked: currentSong.disliked
  1856. }"
  1857. >thumb_down_alt</i
  1858. >{{ currentSong.dislikes }}
  1859. </button>
  1860. </div>
  1861. <div id="ratings" class="disabled" v-else>
  1862. <!-- Like Song Button -->
  1863. <button
  1864. class="button is-success like-song disabled"
  1865. content="Ratings have not been loaded yet"
  1866. v-tippy
  1867. >
  1868. <i
  1869. class="material-icons icon-with-button"
  1870. >thumb_up_alt</i
  1871. >
  1872. </button>
  1873. <!-- Dislike Song Button -->
  1874. <button
  1875. class="button is-danger dislike-song disabled"
  1876. content="Ratings have not been loaded yet"
  1877. v-tippy
  1878. >
  1879. <i
  1880. class="material-icons icon-with-button"
  1881. >thumb_down_alt</i
  1882. >
  1883. </button>
  1884. </div>
  1885. <add-to-playlist-dropdown
  1886. :song="currentSong"
  1887. placement="top-end"
  1888. >
  1889. <template #button>
  1890. <div
  1891. id="add-song-to-playlist"
  1892. content="Add Song to Playlist"
  1893. v-tippy
  1894. >
  1895. <div class="control has-addons">
  1896. <button
  1897. class="button is-primary"
  1898. >
  1899. <i class="material-icons">
  1900. playlist_add
  1901. </i>
  1902. </button>
  1903. <button
  1904. class="button"
  1905. id="dropdown-toggle"
  1906. >
  1907. <i class="material-icons">
  1908. {{
  1909. showPlaylistDropdown
  1910. ? "expand_more"
  1911. : "expand_less"
  1912. }}
  1913. </i>
  1914. </button>
  1915. </div>
  1916. </div>
  1917. </template>
  1918. </add-to-playlist-dropdown>
  1919. </div>
  1920. </div>
  1921. <div
  1922. class="player-container quadrant"
  1923. v-show="
  1924. !noSong &&
  1925. (!experimentalChangableListenModeEnabled ||
  1926. experimentalChangableListenMode ===
  1927. 'listen_and_participate')
  1928. "
  1929. >
  1930. <div id="video-container">
  1931. <div
  1932. v-show="currentSongMediaType === 'youtube'"
  1933. id="youtubeStationPlayer"
  1934. style="
  1935. width: 100%;
  1936. height: 100%;
  1937. min-height: 200px;
  1938. "
  1939. />
  1940. <iframe
  1941. v-show="
  1942. currentSongMediaType === 'soundcloud'
  1943. "
  1944. id="soundcloudStationPlayer"
  1945. ref="soundcloudIframeElement"
  1946. style="
  1947. width: 100%;
  1948. height: 100%;
  1949. min-height: 200px;
  1950. "
  1951. scrolling="no"
  1952. frameborder="no"
  1953. allow="autoplay"
  1954. ></iframe>
  1955. <div
  1956. class="player-cannot-autoplay"
  1957. v-if="!canAutoplay"
  1958. @click="increaseVolume()"
  1959. >
  1960. <p>
  1961. Please click anywhere on the screen for
  1962. the video to start
  1963. </p>
  1964. </div>
  1965. </div>
  1966. <div id="seeker-bar-container">
  1967. <div
  1968. id="seeker-bar"
  1969. :class="{
  1970. 'christmas-seeker': christmas,
  1971. nyan:
  1972. currentSong &&
  1973. currentSong.mediaSource ===
  1974. 'youtube:QH2-TGUlwu4'
  1975. }"
  1976. />
  1977. <div
  1978. class="seeker-bar-cover"
  1979. :style="{
  1980. width: `calc(100% - ${seekerbarPercentage}%)`
  1981. }"
  1982. ></div>
  1983. <img
  1984. v-if="
  1985. currentSong &&
  1986. currentSong.mediaSource ===
  1987. 'youtube:QH2-TGUlwu4'
  1988. "
  1989. src="https://freepngimg.com/thumb/nyan_cat/1-2-nyan-cat-free-download-png.png"
  1990. :style="{
  1991. position: 'absolute',
  1992. top: `-10px`,
  1993. left: `${seekerbarPercentage}%`,
  1994. width: '50px'
  1995. }"
  1996. />
  1997. <img
  1998. v-if="
  1999. currentSong &&
  2000. (currentSong.mediaSource ===
  2001. 'youtube:DtVBCG6ThDk' ||
  2002. currentSong.mediaSource ===
  2003. 'youtube:sI66hcu9fIs' ||
  2004. currentSong.mediaSource ===
  2005. 'youtube:iYYRH4apXDo' ||
  2006. currentSong.mediaSource ===
  2007. 'youtube:tRcPA7Fzebw')
  2008. "
  2009. src="/assets/rocket.svg"
  2010. :style="{
  2011. position: 'absolute',
  2012. top: `-21px`,
  2013. left: `calc(${seekerbarPercentage}% - 35px)`,
  2014. width: '50px',
  2015. transform: 'rotate(45deg)'
  2016. }"
  2017. />
  2018. <img
  2019. v-if="
  2020. currentSong &&
  2021. currentSong.mediaSource ===
  2022. 'youtube:jofNR_WkoCE'
  2023. "
  2024. src="/assets/fox.svg"
  2025. :style="{
  2026. position: 'absolute',
  2027. top: `-21px`,
  2028. left: `calc(${seekerbarPercentage}% - 35px)`,
  2029. width: '50px',
  2030. transform: 'scaleX(-1)',
  2031. opacity: 1
  2032. }"
  2033. />
  2034. <img
  2035. v-if="
  2036. currentSong &&
  2037. (currentSong.mediaSource ===
  2038. 'youtube:l9PxOanFjxQ' ||
  2039. currentSong.mediaSource ===
  2040. 'youtube:xKVcVSYmesU' ||
  2041. currentSong.mediaSource ===
  2042. 'youtube:60ItHLz5WEA' ||
  2043. currentSong.mediaSource ===
  2044. 'youtube:e6vkFbtSGm0')
  2045. "
  2046. src="/assets/old_logo.png"
  2047. :style="{
  2048. position: 'absolute',
  2049. top: `-9px`,
  2050. left: `calc(${seekerbarPercentage}% - 22px)`,
  2051. 'background-color': 'rgb(96, 199, 169)',
  2052. width: '25px',
  2053. height: '25px',
  2054. 'border-radius': '25px'
  2055. }"
  2056. />
  2057. <img
  2058. v-if="
  2059. christmas &&
  2060. currentSong &&
  2061. ![
  2062. 'youtube:QH2-TGUlwu4',
  2063. 'youtube:DtVBCG6ThDk',
  2064. 'youtube:sI66hcu9fIs',
  2065. 'youtube:iYYRH4apXDo',
  2066. 'youtube:tRcPA7Fzebw',
  2067. 'youtube:jofNR_WkoCE',
  2068. 'youtube:l9PxOanFjxQ',
  2069. 'youtube:xKVcVSYmesU',
  2070. 'youtube:60ItHLz5WEA',
  2071. 'youtube:e6vkFbtSGm0'
  2072. ].includes(currentSong.mediaSource)
  2073. "
  2074. src="/assets/santa.png"
  2075. :style="{
  2076. position: 'absolute',
  2077. top: `-30px`,
  2078. left: `calc(${seekerbarPercentage}% - 25px)`,
  2079. height: '50px',
  2080. transform: 'scaleX(-1)'
  2081. }"
  2082. />
  2083. </div>
  2084. <div id="control-bar-container">
  2085. <div id="left-buttons">
  2086. <!-- Debug Box -->
  2087. <button
  2088. v-if="frontendDevMode === 'development'"
  2089. class="button is-primary"
  2090. @click="togglePlayerDebugBox()"
  2091. @dblclick="resetPlayerDebugBox()"
  2092. content="Debug"
  2093. v-tippy
  2094. >
  2095. <i
  2096. class="material-icons icon-with-button"
  2097. >
  2098. bug_report
  2099. </i>
  2100. </button>
  2101. <!-- Local Pause/Resume Button -->
  2102. <button
  2103. class="button is-primary"
  2104. @click="resumeLocalStation()"
  2105. id="local-resume"
  2106. v-if="localPaused"
  2107. content="Unpause Playback"
  2108. v-tippy
  2109. >
  2110. <i class="material-icons">play_arrow</i>
  2111. </button>
  2112. <button
  2113. class="button is-primary"
  2114. @click="pauseLocalStation()"
  2115. id="local-pause"
  2116. v-else
  2117. content="Pause Playback"
  2118. v-tippy
  2119. >
  2120. <i class="material-icons">pause</i>
  2121. </button>
  2122. <!-- Vote to Skip Button -->
  2123. <button
  2124. v-if="!skipVotesLoaded"
  2125. class="button is-primary disabled"
  2126. content="Skip votes have not been loaded yet"
  2127. v-tippy
  2128. >
  2129. <i
  2130. class="material-icons icon-with-button"
  2131. >skip_next</i
  2132. >
  2133. </button>
  2134. <button
  2135. v-else-if="loggedIn"
  2136. :class="[
  2137. 'button',
  2138. 'is-primary',
  2139. { voted: currentSong.voted }
  2140. ]"
  2141. @click="toggleSkipVote()"
  2142. :content="`${
  2143. currentSong.voted
  2144. ? 'Remove vote'
  2145. : 'Vote'
  2146. } to Skip Song`"
  2147. v-tippy
  2148. >
  2149. <i
  2150. class="material-icons icon-with-button"
  2151. >skip_next</i
  2152. >
  2153. {{ currentSong.skipVotes }}
  2154. </button>
  2155. <button
  2156. v-else
  2157. class="button is-primary disabled"
  2158. content="Log in to vote to skip songs"
  2159. v-tippy="{ theme: 'info' }"
  2160. >
  2161. <i
  2162. class="material-icons icon-with-button"
  2163. >skip_next</i
  2164. >
  2165. {{ currentSong.skipVotes }}
  2166. </button>
  2167. <!-- Close player window -->
  2168. <button
  2169. v-if="
  2170. experimentalChangableListenModeEnabled
  2171. "
  2172. class="button is-primary"
  2173. content="Close this player window"
  2174. @click="
  2175. experimentalChangableListenModeChange(
  2176. 'participate'
  2177. )
  2178. "
  2179. v-tippy
  2180. >
  2181. <i
  2182. class="material-icons icon-with-button"
  2183. >cancel_presentation</i
  2184. >
  2185. </button>
  2186. </div>
  2187. <div id="duration">
  2188. <p>
  2189. {{ timeElapsed }} /
  2190. {{
  2191. utils.formatTime(
  2192. currentSong.duration
  2193. )
  2194. }}
  2195. </p>
  2196. </div>
  2197. <p id="volume-control" v-if="!isApple">
  2198. <i
  2199. class="material-icons"
  2200. @click="toggleMute()"
  2201. :content="`${
  2202. muted ? 'Unmute' : 'Mute'
  2203. }`"
  2204. v-tippy
  2205. >{{
  2206. muted
  2207. ? "volume_mute"
  2208. : volumeSliderValue >= 50
  2209. ? "volume_up"
  2210. : "volume_down"
  2211. }}</i
  2212. >
  2213. <input
  2214. v-model="volumeSliderValue"
  2215. type="range"
  2216. min="0"
  2217. max="100"
  2218. class="volume-slider active"
  2219. @change="changeVolume()"
  2220. @input="changeVolume()"
  2221. />
  2222. </p>
  2223. <div id="right-buttons" v-if="loggedIn">
  2224. <!-- Ratings (Like/Dislike) Buttons -->
  2225. <div
  2226. id="ratings"
  2227. v-if="ratingsLoaded && ownRatingsLoaded"
  2228. :class="{
  2229. liked: currentSong.liked,
  2230. disliked: currentSong.disliked
  2231. }"
  2232. >
  2233. <!-- Like Song Button -->
  2234. <button
  2235. class="button is-success like-song"
  2236. id="like-song"
  2237. @click="toggleLike()"
  2238. content="Like Song"
  2239. v-tippy
  2240. >
  2241. <i
  2242. class="material-icons icon-with-button"
  2243. :class="{
  2244. liked: currentSong.liked
  2245. }"
  2246. >thumb_up_alt</i
  2247. >{{ currentSong.likes }}
  2248. </button>
  2249. <!-- Dislike Song Button -->
  2250. <button
  2251. class="button is-danger dislike-song"
  2252. id="dislike-song"
  2253. @click="toggleDislike()"
  2254. content="Dislike Song"
  2255. v-tippy
  2256. >
  2257. <i
  2258. class="material-icons icon-with-button"
  2259. :class="{
  2260. disliked:
  2261. currentSong.disliked
  2262. }"
  2263. >thumb_down_alt</i
  2264. >{{ currentSong.dislikes }}
  2265. </button>
  2266. </div>
  2267. <div id="ratings" class="disabled" v-else>
  2268. <!-- Like Song Button -->
  2269. <button
  2270. class="button is-success like-song disabled"
  2271. id="like-song"
  2272. content="Ratings have not been loaded yet"
  2273. v-tippy
  2274. >
  2275. <i
  2276. class="material-icons icon-with-button"
  2277. >thumb_up_alt</i
  2278. >
  2279. </button>
  2280. <!-- Dislike Song Button -->
  2281. <button
  2282. class="button is-danger dislike-song disabled"
  2283. id="dislike-song"
  2284. content="Ratings have not been loaded yet"
  2285. v-tippy
  2286. >
  2287. <i
  2288. class="material-icons icon-with-button"
  2289. >thumb_down_alt</i
  2290. >
  2291. </button>
  2292. </div>
  2293. <!-- Add Song To Playlist Button & Dropdown -->
  2294. <add-to-playlist-dropdown
  2295. :song="currentSong"
  2296. placement="top-end"
  2297. >
  2298. <template #button>
  2299. <div
  2300. id="add-song-to-playlist"
  2301. content="Add Song to Playlist"
  2302. v-tippy
  2303. >
  2304. <div class="control has-addons">
  2305. <button
  2306. class="button is-primary"
  2307. >
  2308. <i
  2309. class="material-icons"
  2310. >
  2311. playlist_add
  2312. </i>
  2313. </button>
  2314. <button
  2315. class="button"
  2316. id="dropdown-toggle"
  2317. >
  2318. <i
  2319. class="material-icons"
  2320. >
  2321. {{
  2322. showPlaylistDropdown
  2323. ? "expand_more"
  2324. : "expand_less"
  2325. }}
  2326. </i>
  2327. </button>
  2328. </div>
  2329. </div>
  2330. </template>
  2331. </add-to-playlist-dropdown>
  2332. </div>
  2333. <div id="right-buttons" v-else>
  2334. <!-- Disabled Ratings (Like/Dislike) Buttons -->
  2335. <div id="ratings" v-if="ratingsLoaded">
  2336. <!-- Disabled Like Song Button -->
  2337. <button
  2338. class="button is-success disabled"
  2339. id="like-song"
  2340. content="Log in to like songs"
  2341. v-tippy="{ theme: 'info' }"
  2342. >
  2343. <i
  2344. class="material-icons icon-with-button"
  2345. >thumb_up_alt</i
  2346. >{{ currentSong.likes }}
  2347. </button>
  2348. <!-- Disabled Dislike Song Button -->
  2349. <button
  2350. class="button is-danger disabled"
  2351. id="dislike-song"
  2352. content="Log in to dislike songs"
  2353. v-tippy="{ theme: 'info' }"
  2354. >
  2355. <i
  2356. class="material-icons icon-with-button"
  2357. >thumb_down_alt</i
  2358. >{{ currentSong.dislikes }}
  2359. </button>
  2360. </div>
  2361. <div id="ratings" v-else>
  2362. <!-- Disabled Like Song Button -->
  2363. <button
  2364. class="button is-success disabled"
  2365. id="like-song"
  2366. content="Ratings have not been loaded yet"
  2367. v-tippy="{ theme: 'info' }"
  2368. >
  2369. <i
  2370. class="material-icons icon-with-button"
  2371. >thumb_up_alt</i
  2372. >
  2373. </button>
  2374. <!-- Disabled Dislike Song Button -->
  2375. <button
  2376. class="button is-danger disabled"
  2377. id="dislike-song"
  2378. content="Ratings have not been loaded yet"
  2379. v-tippy="{ theme: 'info' }"
  2380. >
  2381. <i
  2382. class="material-icons icon-with-button"
  2383. >thumb_down_alt</i
  2384. >
  2385. </button>
  2386. </div>
  2387. <!-- Disabled Add Song To Playlist Button & Dropdown -->
  2388. <div id="add-song-to-playlist">
  2389. <div class="control has-addons">
  2390. <button
  2391. class="button is-primary disabled"
  2392. content="Log in to add songs to playlist"
  2393. v-tippy="{ theme: 'info' }"
  2394. >
  2395. <i class="material-icons"
  2396. >queue</i
  2397. >
  2398. </button>
  2399. </div>
  2400. </div>
  2401. </div>
  2402. </div>
  2403. </div>
  2404. <p
  2405. class="player-container nothing-here-text"
  2406. v-if="noSong"
  2407. >
  2408. No song is currently playing
  2409. </p>
  2410. <div v-if="!noSong" id="current-next-row">
  2411. <div
  2412. id="currently-playing-container"
  2413. class="quadrant"
  2414. :class="{ 'no-currently-playing': noSong }"
  2415. >
  2416. <song-item
  2417. :key="`songItem-currentSong-${currentSong.mediaSource}`"
  2418. :song="currentSong"
  2419. :duration="false"
  2420. :requested-by="true"
  2421. :requested-type="true"
  2422. header="Currently Playing.."
  2423. />
  2424. </div>
  2425. <div
  2426. v-if="nextSong"
  2427. id="next-up-container"
  2428. class="quadrant"
  2429. >
  2430. <song-item
  2431. :key="`songItem-nextSong-${nextSong.mediaSource}`"
  2432. :song="nextSong"
  2433. :duration="false"
  2434. :requested-by="true"
  2435. :requested-type="true"
  2436. header="Next Up.."
  2437. />
  2438. </div>
  2439. </div>
  2440. </div>
  2441. </div>
  2442. </div>
  2443. <main-footer />
  2444. </div>
  2445. <floating-box
  2446. id="player-debug-box"
  2447. ref="playerDebugBox"
  2448. title="Station Debug"
  2449. >
  2450. <template #body>
  2451. <span><b>No song</b>: {{ noSong }}</span>
  2452. <span><b>Song id</b>: {{ currentSong._id }}</span>
  2453. <span><b>Media source</b>: {{ currentSong.mediaSource }}</span>
  2454. <span><b>Duration</b>: {{ currentSong.duration }}</span>
  2455. <span
  2456. ><b>Skip duration</b>: {{ currentSong.skipDuration }}</span
  2457. >
  2458. <span><b>Loading</b>: {{ loading }}</span>
  2459. <span><b>Can autoplay</b>: {{ canAutoplay }}</span>
  2460. <span
  2461. ><b>Youtube player ready</b>: {{ youtubePlayerReady }}</span
  2462. >
  2463. <span
  2464. ><b>Attempts to play video</b>:
  2465. {{ attemptsToPlayVideo }}</span
  2466. >
  2467. <span
  2468. ><b>Last time requested if can autoplay</b>:
  2469. {{ lastTimeRequestedIfCanAutoplay }}</span
  2470. >
  2471. <span><b>Seeking</b>: {{ seeking }}</span>
  2472. <span><b>Playback rate</b>: {{ playbackRate }}</span>
  2473. <span><b>System difference</b>: {{ systemDifference }}</span>
  2474. <span><b>Time before paused</b>: {{ timeBeforePause }}</span>
  2475. <span><b>Time paused</b>: {{ timePaused }}</span>
  2476. <span><b>Time elapsed</b>: {{ timeElapsed }}</span>
  2477. <span><b>Volume slider value</b>: {{ volumeSliderValue }}</span>
  2478. <span><b>Local paused</b>: {{ localPaused }}</span>
  2479. <span><b>Station paused</b>: {{ stationPaused }}</span>
  2480. <span :title="new Date(pausedAt).toString()"
  2481. ><b>Paused at</b>: {{ pausedAt }}</span
  2482. >
  2483. <span :title="new Date(startedAt).toString()"
  2484. ><b>Started at</b>: {{ startedAt }}</span
  2485. >
  2486. <span
  2487. ><b>Requests enabled</b>:
  2488. {{ station.requests.enabled }}</span
  2489. >
  2490. <span
  2491. ><b>Requests access</b>: {{ station.requests.access }}</span
  2492. >
  2493. <span><b>Requests limit</b>: {{ station.requests.limit }}</span>
  2494. <span
  2495. ><b>Auto requesting playlists</b>:
  2496. {{
  2497. autoRequest.map(playlist => playlist._id).join(", ")
  2498. }}</span
  2499. >
  2500. <span
  2501. ><b>Autofill enabled</b>:
  2502. {{ station.autofill.enabled }}</span
  2503. >
  2504. <span><b>Autofill limit</b>: {{ station.autofill.limit }}</span>
  2505. <span><b>Autofill mode</b>: {{ station.autofill.mode }}</span>
  2506. <span><b>Skip votes loaded</b>: {{ skipVotesLoaded }}</span>
  2507. <span
  2508. ><b>Skip votes current</b>:
  2509. {{
  2510. currentSong.skipVotesCurrent
  2511. ? currentSong.skipVotesCurrent
  2512. : "N/A"
  2513. }}</span
  2514. >
  2515. <span
  2516. ><b>Skip votes</b>:
  2517. {{ skipVotesLoaded ? currentSong.skipVotes : "N/A" }}</span
  2518. >
  2519. <span><b>Ratings loaded</b>: {{ ratingsLoaded }}</span>
  2520. <span
  2521. ><b>Ratings</b>:
  2522. {{
  2523. ratingsLoaded
  2524. ? `${currentSong.likes} / ${currentSong.dislikes}`
  2525. : "N/A"
  2526. }}</span
  2527. >
  2528. <span><b>Own ratings loaded</b>: {{ ownRatingsLoaded }}</span>
  2529. <span
  2530. ><b>Own ratings</b>:
  2531. {{
  2532. ownRatingsLoaded
  2533. ? `${currentSong.liked} / ${currentSong.disliked}`
  2534. : "N/A"
  2535. }}</span
  2536. >
  2537. </template>
  2538. </floating-box>
  2539. <floating-box
  2540. id="keyboardShortcutsHelper"
  2541. ref="keyboardShortcutsHelper"
  2542. title="Station Keyboard Shortcuts"
  2543. >
  2544. <template #body>
  2545. <div>
  2546. <div
  2547. v-if="
  2548. hasPermission('stations.playback.toggle') ||
  2549. hasPermission('stations.skip')
  2550. "
  2551. >
  2552. <span class="biggest"><b>Admin/owner</b></span>
  2553. <span><b>Ctrl + Space</b> - Pause/resume station</span>
  2554. <span><b>Ctrl + Numpad right</b> - Skip station</span>
  2555. </div>
  2556. <hr
  2557. v-if="
  2558. hasPermission('stations.playback.toggle') ||
  2559. hasPermission('stations.skip')
  2560. "
  2561. />
  2562. <div>
  2563. <span class="biggest"><b>Volume</b></span>
  2564. <span
  2565. ><b>Ctrl + Numpad up/down</b> - Volume up/down
  2566. 10%</span
  2567. >
  2568. <span
  2569. ><b>Ctrl + Shift + Numpad up/down</b> - Volume
  2570. up/down 10%</span
  2571. >
  2572. </div>
  2573. <hr />
  2574. <div>
  2575. <span class="biggest"><b>Misc</b></span>
  2576. <span><b>Ctrl + D</b> - Toggles debug box</span>
  2577. <span><b>Ctrl + Shift + D</b> - Resets debug box</span>
  2578. <span
  2579. ><b>Ctrl + /</b> - Toggles keyboard shortcuts
  2580. box</span
  2581. >
  2582. <span
  2583. ><b>Ctrl + Shift + /</b> - Resets keyboard shortcuts
  2584. box</span
  2585. >
  2586. </div>
  2587. </div>
  2588. </template>
  2589. </floating-box>
  2590. <Z404 v-if="!exists"></Z404>
  2591. </div>
  2592. </template>
  2593. <style lang="less">
  2594. #youtubeStationPlayer,
  2595. #soundcloudStationPlayer {
  2596. position: absolute;
  2597. top: 0;
  2598. left: 0;
  2599. width: 100%;
  2600. height: 100%;
  2601. }
  2602. #currently-playing-container,
  2603. #next-up-container {
  2604. .song-item {
  2605. min-height: 130px;
  2606. .thumbnail {
  2607. min-width: 130px;
  2608. width: 130px;
  2609. height: 130px;
  2610. }
  2611. .song-info {
  2612. margin-left: 130px;
  2613. }
  2614. }
  2615. }
  2616. #control-bar-container
  2617. #right-buttons
  2618. .tippy-box[data-theme~="dropdown"]
  2619. .nav-dropdown-items {
  2620. padding-bottom: 0 !important;
  2621. }
  2622. </style>
  2623. <style lang="less" scoped>
  2624. #page-loader-container {
  2625. height: inherit;
  2626. #page-loader-content {
  2627. height: inherit;
  2628. position: absolute;
  2629. max-width: 100%;
  2630. width: 1800px;
  2631. transform: translateX(-50%);
  2632. left: 50%;
  2633. }
  2634. #page-loader-layout {
  2635. height: inherit;
  2636. width: 100%;
  2637. }
  2638. }
  2639. #mobile-progress-animation {
  2640. width: 50px;
  2641. animation: rotate 0.8s infinite linear;
  2642. border: 8px solid var(--primary-color);
  2643. border-right-color: transparent;
  2644. border-radius: 50%;
  2645. height: 50px;
  2646. position: absolute;
  2647. top: 50%;
  2648. left: 50%;
  2649. display: none;
  2650. }
  2651. @keyframes rotate {
  2652. 0% {
  2653. transform: rotate(0deg);
  2654. }
  2655. 100% {
  2656. transform: rotate(360deg);
  2657. }
  2658. }
  2659. .nav,
  2660. .button.is-primary {
  2661. background-color: var(--primary-color) !important;
  2662. }
  2663. .button.is-primary:hover,
  2664. .button.is-primary:focus {
  2665. filter: brightness(90%);
  2666. }
  2667. .night-mode {
  2668. #currently-playing-container,
  2669. #next-up-container,
  2670. #control-bar-container,
  2671. .quadrant:not(#sidebar-container),
  2672. .player-container {
  2673. background-color: var(--dark-grey-3) !important;
  2674. }
  2675. #video-container,
  2676. #control-bar-container,
  2677. .quadrant:not(#sidebar-container),
  2678. .player-container {
  2679. border: 0 !important;
  2680. }
  2681. #seeker-bar-container {
  2682. background-color: var(--dark-grey-3) !important;
  2683. }
  2684. #dropdown-toggle {
  2685. background-color: var(--dark-grey-2) !important;
  2686. border: 0;
  2687. i {
  2688. color: var(--white);
  2689. }
  2690. }
  2691. }
  2692. #station-outer-container {
  2693. margin: 0 auto;
  2694. padding: 20px 40px;
  2695. min-height: calc(100vh - 64px);
  2696. width: 100%;
  2697. max-width: 1800px;
  2698. display: flex;
  2699. #station-inner-container {
  2700. width: 100%;
  2701. min-height: calc(100vh - 428px);
  2702. display: flex;
  2703. flex-direction: row;
  2704. flex-wrap: wrap;
  2705. .row {
  2706. display: flex;
  2707. flex-direction: row;
  2708. max-width: 100%;
  2709. }
  2710. .column {
  2711. display: flex;
  2712. flex-direction: column;
  2713. }
  2714. .quadrant {
  2715. border-radius: @border-radius;
  2716. margin: 10px;
  2717. overflow: hidden;
  2718. }
  2719. .quadrant:not(#sidebar-container) {
  2720. background-color: var(--white);
  2721. border: 1px solid var(--light-grey-3);
  2722. }
  2723. #station-left-column,
  2724. #station-right-column {
  2725. padding: 0;
  2726. }
  2727. #current-next-row {
  2728. display: flex;
  2729. flex-direction: row;
  2730. #currently-playing-container,
  2731. #next-up-container {
  2732. overflow: hidden;
  2733. flex-basis: 50%;
  2734. .song-item {
  2735. border: unset;
  2736. }
  2737. .nothing-here-text {
  2738. height: 100%;
  2739. }
  2740. }
  2741. > div:only-child {
  2742. flex: 1 !important;
  2743. flex-basis: 100% !important;
  2744. }
  2745. }
  2746. .player-container {
  2747. height: inherit;
  2748. background-color: var(--white);
  2749. display: flex;
  2750. flex-direction: column;
  2751. border: 1px solid var(--light-grey-3);
  2752. border-radius: @border-radius;
  2753. overflow: hidden;
  2754. &.nothing-here-text {
  2755. margin: 10px;
  2756. flex: 1;
  2757. min-height: 487px;
  2758. }
  2759. #video-container {
  2760. position: relative;
  2761. padding-bottom: 56.25%; /* proportion value to aspect ratio 16:9 (9 / 16 = 0.5625 or 56.25%) */
  2762. height: 0;
  2763. overflow: hidden;
  2764. .player-cannot-autoplay {
  2765. position: relative;
  2766. width: 100%;
  2767. height: 100%;
  2768. bottom: calc(100% + 5px);
  2769. background: var(--primary-color);
  2770. display: flex;
  2771. align-items: center;
  2772. justify-content: center;
  2773. p {
  2774. color: var(--white);
  2775. font-size: 26px;
  2776. text-align: center;
  2777. }
  2778. }
  2779. }
  2780. #seeker-bar-container {
  2781. background-color: var(--white);
  2782. position: relative;
  2783. height: 7px;
  2784. display: block;
  2785. width: 100%;
  2786. #seeker-bar {
  2787. background-color: var(--primary-color);
  2788. top: 0;
  2789. left: 0;
  2790. bottom: 0;
  2791. position: absolute;
  2792. width: 100%;
  2793. }
  2794. .seeker-bar-cover {
  2795. position: absolute;
  2796. top: 0;
  2797. right: 0;
  2798. bottom: 0;
  2799. background-color: inherit;
  2800. }
  2801. }
  2802. #control-bar-container {
  2803. display: flex;
  2804. justify-content: space-around;
  2805. padding: 10px 0;
  2806. width: 100%;
  2807. background: var(--white);
  2808. flex-direction: column;
  2809. flex-flow: wrap;
  2810. .button:not(#dropdown-toggle) {
  2811. width: 75px;
  2812. }
  2813. #left-buttons,
  2814. #right-buttons {
  2815. margin: 3px;
  2816. }
  2817. #left-buttons {
  2818. display: flex;
  2819. .button:not(:first-of-type) {
  2820. margin-left: 5px;
  2821. }
  2822. .disabled {
  2823. filter: grayscale(0.4);
  2824. }
  2825. }
  2826. #duration {
  2827. margin: 3px;
  2828. display: flex;
  2829. align-items: center;
  2830. p {
  2831. font-size: 22px;
  2832. /** prevents duration width slightly varying and shifting other controls slightly */
  2833. width: 150px;
  2834. text-align: center;
  2835. }
  2836. }
  2837. #volume-control {
  2838. margin: 3px;
  2839. margin-top: 0;
  2840. display: flex;
  2841. align-items: center;
  2842. cursor: pointer;
  2843. .volume-slider {
  2844. width: 100%;
  2845. padding: 0 15px;
  2846. background: transparent;
  2847. min-width: 100px;
  2848. }
  2849. input[type="range"] {
  2850. -webkit-appearance: none;
  2851. margin: 7.3px 0;
  2852. }
  2853. input[type="range"]:focus {
  2854. outline: none;
  2855. }
  2856. input[type="range"]::-webkit-slider-runnable-track {
  2857. width: 100%;
  2858. height: 5.2px;
  2859. cursor: pointer;
  2860. box-shadow: 0;
  2861. background: var(--light-grey-3);
  2862. border-radius: @border-radius;
  2863. border: 0;
  2864. }
  2865. input[type="range"]::-webkit-slider-thumb {
  2866. box-shadow: 0;
  2867. border: 0;
  2868. height: 19px;
  2869. width: 19px;
  2870. border-radius: 100%;
  2871. background: var(--primary-color);
  2872. cursor: pointer;
  2873. -webkit-appearance: none;
  2874. margin-top: -6.5px;
  2875. }
  2876. input[type="range"]::-moz-range-track {
  2877. width: 100%;
  2878. height: 5.2px;
  2879. cursor: pointer;
  2880. box-shadow: 0;
  2881. background: var(--light-grey-3);
  2882. border-radius: @border-radius;
  2883. border: 0;
  2884. }
  2885. input[type="range"]::-moz-range-thumb {
  2886. box-shadow: 0;
  2887. border: 0;
  2888. height: 19px;
  2889. width: 19px;
  2890. border-radius: 100%;
  2891. background: var(--primary-color);
  2892. cursor: pointer;
  2893. -webkit-appearance: none;
  2894. margin-top: -6.5px;
  2895. }
  2896. input[type="range"]::-ms-track {
  2897. width: 100%;
  2898. height: 5.2px;
  2899. cursor: pointer;
  2900. box-shadow: 0;
  2901. background: var(--light-grey-3);
  2902. border-radius: @border-radius;
  2903. }
  2904. input[type="range"]::-ms-fill-lower {
  2905. background: var(--light-grey-3);
  2906. border: 0;
  2907. border-radius: 0;
  2908. box-shadow: 0;
  2909. }
  2910. input[type="range"]::-ms-fill-upper {
  2911. background: var(--light-grey-3);
  2912. border: 0;
  2913. border-radius: 0;
  2914. box-shadow: 0;
  2915. }
  2916. input[type="range"]::-ms-thumb {
  2917. box-shadow: 0;
  2918. border: 0;
  2919. height: 15px;
  2920. width: 15px;
  2921. border-radius: 100%;
  2922. background: var(--primary-color);
  2923. cursor: pointer;
  2924. -webkit-appearance: none;
  2925. margin-top: 1.5px;
  2926. }
  2927. }
  2928. #right-buttons {
  2929. display: flex;
  2930. #dropdown-toggle {
  2931. width: 35px;
  2932. }
  2933. #dislike-song,
  2934. #add-song-to-playlist .button:not(#dropdown-toggle) {
  2935. margin-left: 5px;
  2936. }
  2937. #ratings {
  2938. display: flex;
  2939. &.liked #dislike-song,
  2940. &.disliked #like-song {
  2941. background-color: var(--grey) !important;
  2942. }
  2943. #like-song.disabled,
  2944. #dislike-song.disabled {
  2945. filter: grayscale(0.4);
  2946. }
  2947. }
  2948. #add-song-to-playlist {
  2949. display: flex;
  2950. flex-direction: column-reverse;
  2951. #nav-dropdown {
  2952. position: absolute;
  2953. margin-left: 4px;
  2954. margin-bottom: 36px;
  2955. .nav-dropdown-items {
  2956. position: relative;
  2957. right: calc(100% - 110px);
  2958. }
  2959. }
  2960. .control {
  2961. width: fit-content;
  2962. margin-bottom: 0 !important;
  2963. button.disabled {
  2964. filter: grayscale(0.4);
  2965. border-radius: @border-radius;
  2966. &::after {
  2967. margin-right: 100%;
  2968. }
  2969. }
  2970. }
  2971. }
  2972. }
  2973. }
  2974. }
  2975. #sidebar-container {
  2976. border-top: 0;
  2977. position: relative;
  2978. height: inherit;
  2979. flex-grow: 1;
  2980. min-height: 350px;
  2981. }
  2982. }
  2983. }
  2984. .footer {
  2985. margin-top: 30px;
  2986. }
  2987. .nyan {
  2988. background: linear-gradient(
  2989. 90deg,
  2990. magenta 0%,
  2991. red 15%,
  2992. orange 30%,
  2993. yellow 45%,
  2994. lime 60%,
  2995. cyan 75%,
  2996. blue 90%,
  2997. magenta 100%
  2998. );
  2999. background-size: 200%;
  3000. animation: nyanMoving 4s linear infinite;
  3001. }
  3002. @keyframes nyanMoving {
  3003. 0% {
  3004. background-position: 0% 0%;
  3005. }
  3006. 100% {
  3007. background-position: -200% 0%;
  3008. }
  3009. }
  3010. .christmas-seeker {
  3011. background: repeating-linear-gradient(
  3012. -45deg,
  3013. var(--white) 0 1rem,
  3014. var(--dark-red) 1rem 2rem
  3015. );
  3016. background-size: 200% 100%;
  3017. animation: christmas 20s linear infinite;
  3018. }
  3019. @keyframes christmas {
  3020. 100% {
  3021. background-position: 80% 100%;
  3022. }
  3023. }
  3024. .bg-bubbles {
  3025. top: 0;
  3026. left: 0;
  3027. width: 100%;
  3028. height: 100%;
  3029. position: absolute;
  3030. z-index: -1;
  3031. margin: 0px;
  3032. pointer-events: none;
  3033. }
  3034. .bg-bubbles li {
  3035. position: absolute;
  3036. list-style: none;
  3037. display: block;
  3038. width: 40px;
  3039. height: 40px;
  3040. border-radius: 100px;
  3041. background-color: var(--primary-color);
  3042. opacity: 0.15;
  3043. bottom: 0px;
  3044. -webkit-animation: square 25s infinite;
  3045. animation: square 25s infinite;
  3046. -webkit-transition-timing-function: linear;
  3047. transition-timing-function: linear;
  3048. }
  3049. .bg-bubbles li:nth-child(1) {
  3050. left: 10%;
  3051. }
  3052. .bg-bubbles li:nth-child(2) {
  3053. left: 20%;
  3054. width: 80px;
  3055. height: 80px;
  3056. -webkit-animation-delay: 2s;
  3057. animation-delay: 2s;
  3058. -webkit-animation-duration: 17s;
  3059. animation-duration: 17s;
  3060. }
  3061. .bg-bubbles li:nth-child(3) {
  3062. left: 25%;
  3063. -webkit-animation-delay: 4s;
  3064. animation-delay: 4s;
  3065. }
  3066. .bg-bubbles li:nth-child(4) {
  3067. left: 40%;
  3068. width: 60px;
  3069. height: 60px;
  3070. -webkit-animation-duration: 22s;
  3071. animation-duration: 22s;
  3072. background-color: var(--primary-color);
  3073. opacity: 0.25;
  3074. }
  3075. .bg-bubbles li:nth-child(5) {
  3076. left: 70%;
  3077. }
  3078. .bg-bubbles li:nth-child(6) {
  3079. left: 80%;
  3080. width: 120px;
  3081. height: 120px;
  3082. -webkit-animation-delay: 3s;
  3083. animation-delay: 3s;
  3084. background-color: var(--primary-color);
  3085. opacity: 0.2;
  3086. }
  3087. .bg-bubbles li:nth-child(7) {
  3088. left: 32%;
  3089. width: 160px;
  3090. height: 160px;
  3091. -webkit-animation-delay: 7s;
  3092. animation-delay: 7s;
  3093. }
  3094. .bg-bubbles li:nth-child(8) {
  3095. left: 55%;
  3096. width: 20px;
  3097. height: 20px;
  3098. -webkit-animation-delay: 15s;
  3099. animation-delay: 15s;
  3100. -webkit-animation-duration: 40s;
  3101. animation-duration: 40s;
  3102. }
  3103. .bg-bubbles li:nth-child(9) {
  3104. left: 25%;
  3105. width: 10px;
  3106. height: 10px;
  3107. -webkit-animation-delay: 2s;
  3108. animation-delay: 2s;
  3109. -webkit-animation-duration: 40s;
  3110. animation-duration: 40s;
  3111. background-color: var(--primary-color);
  3112. opacity: 0.3;
  3113. }
  3114. .bg-bubbles li:nth-child(10) {
  3115. left: 80%;
  3116. width: 160px;
  3117. height: 160px;
  3118. -webkit-animation-delay: 11s;
  3119. animation-delay: 11s;
  3120. }
  3121. .experimental-listen-mode-container {
  3122. display: flex;
  3123. flex-direction: column;
  3124. justify-content: center;
  3125. row-gap: 16px;
  3126. padding: 16px 16px;
  3127. .row {
  3128. display: flex;
  3129. flex-direction: row;
  3130. column-gap: 16px;
  3131. .ratings {
  3132. flex: 2;
  3133. display: flex;
  3134. flex-direction: row;
  3135. column-gap: 16px;
  3136. button {
  3137. flex: 1;
  3138. }
  3139. }
  3140. .addToPlaylistDropdown {
  3141. flex: 1;
  3142. .button.is-primary {
  3143. flex: 1;
  3144. }
  3145. }
  3146. }
  3147. }
  3148. /* Tablet view fix */
  3149. @media (max-width: 768px) {
  3150. .bg-bubbles li:nth-child(10) {
  3151. display: none;
  3152. }
  3153. .experimental-listen-mode-container {
  3154. row-gap: 8px;
  3155. .row {
  3156. column-gap: 8px;
  3157. .ratings {
  3158. column-gap: 8px;
  3159. }
  3160. }
  3161. }
  3162. }
  3163. @-webkit-keyframes square {
  3164. 0% {
  3165. -webkit-transform: translateY(0);
  3166. transform: translateY(0);
  3167. }
  3168. 100% {
  3169. -webkit-transform: translateY(-700px) rotate(600deg);
  3170. transform: translateY(-700px) rotate(600deg);
  3171. }
  3172. }
  3173. @keyframes square {
  3174. 0% {
  3175. -webkit-transform: translateY(0);
  3176. transform: translateY(0);
  3177. }
  3178. 100% {
  3179. -webkit-transform: translateY(-700px) rotate(600deg);
  3180. transform: translateY(-700px) rotate(600deg);
  3181. }
  3182. }
  3183. :deep(.nothing-here-text) {
  3184. display: flex;
  3185. align-items: center;
  3186. justify-content: center;
  3187. }
  3188. @media (min-width: 1500px) {
  3189. #station-left-column {
  3190. max-width: 650px;
  3191. }
  3192. #station-right-column {
  3193. max-width: calc(100% - 650px);
  3194. }
  3195. }
  3196. @media (max-width: 1700px) {
  3197. #current-next-row {
  3198. flex-direction: column !important;
  3199. > div {
  3200. flex: 1 !important;
  3201. }
  3202. }
  3203. }
  3204. @media (max-width: 1500px) {
  3205. #mobile-progress-animation {
  3206. display: block;
  3207. }
  3208. #page-loader-container {
  3209. display: none;
  3210. }
  3211. #station-outer-container {
  3212. max-width: 1500px;
  3213. #station-inner-container {
  3214. flex-direction: row;
  3215. #station-left-column {
  3216. #about-station-container #admin-buttons {
  3217. flex-wrap: wrap;
  3218. }
  3219. #sidebar-container {
  3220. min-height: 350px;
  3221. }
  3222. }
  3223. #station-right-column {
  3224. #current-next-row {
  3225. flex-direction: column;
  3226. }
  3227. #control-bar-container {
  3228. #duration,
  3229. #volume-control,
  3230. #right-buttons,
  3231. #left-buttons {
  3232. margin-bottom: 5px;
  3233. justify-content: center;
  3234. }
  3235. #duration {
  3236. order: 1;
  3237. }
  3238. #volume-control {
  3239. order: 2;
  3240. max-width: 400px;
  3241. }
  3242. #right-buttons {
  3243. order: 3;
  3244. flex-wrap: wrap;
  3245. #ratings {
  3246. flex-wrap: wrap;
  3247. }
  3248. }
  3249. #left-buttons {
  3250. order: 4;
  3251. flex-wrap: wrap;
  3252. }
  3253. }
  3254. }
  3255. }
  3256. }
  3257. }
  3258. @media (max-width: 1200px) {
  3259. #station-outer-container {
  3260. max-width: 900px;
  3261. padding: 0;
  3262. #station-inner-container {
  3263. flex-direction: column-reverse;
  3264. flex-wrap: nowrap;
  3265. }
  3266. }
  3267. }
  3268. @media (max-width: 990px) {
  3269. #station-outer-container {
  3270. min-height: calc(
  3271. 100vh - 256px
  3272. ); // Height of nav (64px) + height of footer (190px)
  3273. }
  3274. }
  3275. </style>