index.vue 77 KB

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