index.vue 76 KB

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