index.vue 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946
  1. <template>
  2. <div>
  3. <metadata v-if="exists && !loading" :title="`${station.displayName}`" />
  4. <metadata v-else-if="!exists && !loading" :title="`Not found`" />
  5. <main-header v-if="exists" />
  6. <div id="station-outer-container">
  7. <div v-show="loading" class="progress" />
  8. <div v-show="!loading && exists" id="station-inner-container">
  9. <div id="upper-row" class="row">
  10. <div id="about-station-container" class="quadrant">
  11. <div class="row" id="station-name">
  12. <h1>{{ station.displayName }}</h1>
  13. <a href="#">
  14. <!-- Favourite Station Button -->
  15. <i
  16. v-if="loggedIn && favoriteStation"
  17. @click="unfavoriteStation($event)"
  18. class="material-icons"
  19. >star</i
  20. >
  21. <i
  22. v-if="loggedIn && !favoriteStation"
  23. @click="addfavoriteStation($event)"
  24. class="material-icons"
  25. >star_border</i
  26. >
  27. </a>
  28. </div>
  29. <p>{{ station.description }}</p>
  30. <div id="admin-buttons" v-if="isOwnerOrAdmin()">
  31. <!-- (Admin) Station Settings Button -->
  32. <button
  33. class="button is-primary"
  34. @click="openSettings()"
  35. >
  36. <i class="material-icons icon-with-button"
  37. >settings</i
  38. >
  39. <span class="optional-desktop-only-text">
  40. Station settings
  41. </span>
  42. </button>
  43. <!-- (Admin) Skip Button -->
  44. <button
  45. class="button is-danger"
  46. @click="skipStation()"
  47. >
  48. <i class="material-icons icon-with-button"
  49. >skip_next</i
  50. >
  51. <span class="optional-desktop-only-text">
  52. Force Skip
  53. </span>
  54. </button>
  55. <!-- (Admin) Pause/Resume Button -->
  56. <button
  57. class="button is-danger"
  58. v-if="stationPaused"
  59. @click="resumeStation()"
  60. >
  61. <i class="material-icons icon-with-button"
  62. >play_arrow</i
  63. >
  64. <span class="optional-desktop-only-text">
  65. Resume Station
  66. </span>
  67. </button>
  68. <button
  69. class="button is-danger"
  70. @click="pauseStation()"
  71. v-else
  72. >
  73. <i class="material-icons icon-with-button"
  74. >pause</i
  75. >
  76. <span class="optional-desktop-only-text">
  77. Pause Station
  78. </span>
  79. </button>
  80. </div>
  81. </div>
  82. <div
  83. id="currently-playing-container"
  84. class="quadrant"
  85. :class="{ 'no-currently-playing': noSong }"
  86. >
  87. <currently-playing v-if="!noSong" />
  88. <p v-else class="nothing-here">
  89. No song is currently playing
  90. </p>
  91. </div>
  92. </div>
  93. <div id="lower-row" class="row">
  94. <div class="player-container quadrant" v-show="!noSong">
  95. <div id="video-container">
  96. <div
  97. id="player"
  98. style="width: 100%; height: 100%"
  99. />
  100. <div
  101. class="player-cannot-autoplay"
  102. v-if="!canAutoplay"
  103. >
  104. <p>
  105. Please click anywhere on the screen for the
  106. video to start
  107. </p>
  108. </div>
  109. </div>
  110. <div id="seeker-bar-container">
  111. <div id="seeker-bar" style="width: 0%" />
  112. </div>
  113. <div id="control-bar-container">
  114. <div id="left-buttons">
  115. <!-- Debug Box -->
  116. <button
  117. class="button is-primary"
  118. @click="togglePlayerDebugBox()"
  119. @dblclick="resetPlayerDebugBox()"
  120. >
  121. <i class="material-icons icon-with-button">
  122. bug_report
  123. </i>
  124. <span class="optional-desktop-only-text">
  125. Debug
  126. </span>
  127. </button>
  128. <!-- Local Pause/Resume Button -->
  129. <button
  130. class="button is-primary"
  131. @click="resumeLocalStation()"
  132. id="local-resume"
  133. v-if="localPaused"
  134. >
  135. <i class="material-icons">play_arrow</i>
  136. <span class="optional-desktop-only-text"
  137. >Play locally</span
  138. >
  139. </button>
  140. <button
  141. class="button is-primary"
  142. @click="pauseLocalStation()"
  143. id="local-pause"
  144. v-else
  145. >
  146. <i class="material-icons">pause</i>
  147. <span class="optional-desktop-only-text"
  148. >Pause locally</span
  149. >
  150. </button>
  151. <!-- Vote to Skip Button -->
  152. <button
  153. v-if="loggedIn"
  154. class="button is-primary"
  155. @click="voteSkipStation()"
  156. >
  157. <i class="material-icons icon-with-button"
  158. >skip_next</i
  159. >
  160. <span class="optional-desktop-only-text"
  161. >Vote to skip (</span
  162. >
  163. {{ currentSong.skipVotes }}
  164. <span class="optional-desktop-only-text"
  165. >)</span
  166. >
  167. </button>
  168. </div>
  169. <div id="duration">
  170. <p>
  171. {{ timeElapsed }} /
  172. {{ utils.formatTime(currentSong.duration) }}
  173. </p>
  174. </div>
  175. <p id="volume-control">
  176. <i
  177. v-if="muted"
  178. class="material-icons"
  179. @click="toggleMute()"
  180. >volume_mute</i
  181. >
  182. <i
  183. v-else
  184. class="material-icons"
  185. @click="toggleMute()"
  186. >volume_down</i
  187. >
  188. <input
  189. v-model="volumeSliderValue"
  190. type="range"
  191. min="0"
  192. max="10000"
  193. class="volume-slider active"
  194. @change="changeVolume()"
  195. @input="changeVolume()"
  196. />
  197. <i
  198. class="material-icons"
  199. @click="increaseVolume()"
  200. >volume_up</i
  201. >
  202. </p>
  203. <div id="right-buttons" v-if="loggedIn">
  204. <!-- Ratings (Like/Dislike) Buttons -->
  205. <div
  206. id="ratings"
  207. v-if="
  208. currentSong.likes !== -1 &&
  209. currentSong.dislikes !== -1
  210. "
  211. :class="{
  212. liked: liked,
  213. disliked: disliked
  214. }"
  215. >
  216. <!-- Like Song Button -->
  217. <button
  218. class="button is-success"
  219. id="like-song"
  220. @click="toggleLike()"
  221. >
  222. <i
  223. class="material-icons icon-with-button"
  224. :class="{ liked: liked }"
  225. >thumb_up_alt</i
  226. >{{ currentSong.likes }}
  227. </button>
  228. <!-- Dislike Song Button -->
  229. <button
  230. class="button is-danger"
  231. id="dislike-song"
  232. @click="toggleDislike()"
  233. >
  234. <i
  235. class="material-icons icon-with-button"
  236. :class="{
  237. disliked: disliked
  238. }"
  239. >thumb_down_alt</i
  240. >{{ currentSong.dislikes }}
  241. </button>
  242. </div>
  243. <!-- Add Song To Playlist Button & Dropdown -->
  244. <div id="add-song-to-playlist">
  245. <div class="control has-addons">
  246. <button
  247. class="button is-primary"
  248. @click="
  249. showPlaylistDropdown = !showPlaylistDropdown
  250. "
  251. >
  252. <i class="material-icons">queue</i>
  253. <span
  254. class="optional-desktop-only-text"
  255. >Add Song To Playlist</span
  256. >
  257. </button>
  258. <button
  259. class="button"
  260. id="dropdown-toggle"
  261. @click="
  262. showPlaylistDropdown = !showPlaylistDropdown
  263. "
  264. >
  265. <i class="material-icons">
  266. {{
  267. showPlaylistDropdown
  268. ? "expand_more"
  269. : "expand_less"
  270. }}
  271. </i>
  272. </button>
  273. </div>
  274. <add-to-playlist-dropdown
  275. v-if="showPlaylistDropdown"
  276. />
  277. </div>
  278. </div>
  279. </div>
  280. </div>
  281. <p class="player-container nothing-here" v-if="noSong">
  282. No song is currently playing
  283. </p>
  284. <div id="sidebar-container" class="quadrant">
  285. <station-sidebar />
  286. </div>
  287. </div>
  288. </div>
  289. <song-queue v-if="modals.addSongToQueue" />
  290. <edit-playlist v-if="modals.editPlaylist" />
  291. <create-playlist v-if="modals.createPlaylist" />
  292. <edit-station v-if="modals.editStation" store="station" />
  293. <report v-if="modals.report" />
  294. </div>
  295. <main-footer />
  296. <floating-box id="player-debug-box" ref="playerDebugBox">
  297. <template #body>
  298. <span><b>YouTube id</b>: {{ currentSong.songId }}</span>
  299. <span><b>Duration</b>: {{ currentSong.duration }}</span>
  300. <span
  301. ><b>Skip duration</b>: {{ currentSong.skipDuration }}</span
  302. >
  303. <span><b>Can autoplay</b>: {{ canAutoplay }}</span>
  304. <span
  305. ><b>Attempts to play video</b>:
  306. {{ attemptsToPlayVideo }}</span
  307. >
  308. <span
  309. ><b>Last time requested if can autoplay</b>:
  310. {{ lastTimeRequestedIfCanAutoplay }}</span
  311. >
  312. <span><b>Loading</b>: {{ loading }}</span>
  313. <span><b>Playback rate</b>: {{ playbackRate }}</span>
  314. <span><b>Player ready</b>: {{ playerReady }}</span>
  315. <span><b>Ready</b>: {{ ready }}</span>
  316. <span><b>Seeking</b>: {{ seeking }}</span>
  317. <span><b>System difference</b>: {{ systemDifference }}</span>
  318. <span><b>Time before paused</b>: {{ timeBeforePause }}</span>
  319. <span><b>Time elapsed</b>: {{ timeElapsed }}</span>
  320. <span><b>Time paused</b>: {{ timePaused }}</span>
  321. <span><b>Volume slider value</b>: {{ volumeSliderValue }}</span>
  322. <span><b>Local paused</b>: {{ localPaused }}</span>
  323. <span><b>No song</b>: {{ noSong }}</span>
  324. <span
  325. ><b>Private playlist queue selected</b>:
  326. {{ privatePlaylistQueueSelected }}</span
  327. >
  328. <span><b>Station paused</b>: {{ stationPaused }}</span>
  329. </template>
  330. </floating-box>
  331. <Z404 v-if="!exists"></Z404>
  332. </div>
  333. </template>
  334. <script>
  335. import { mapState, mapActions } from "vuex";
  336. import Toast from "toasters";
  337. import MainHeader from "../../components/layout/MainHeader.vue";
  338. import MainFooter from "../../components/layout/MainFooter.vue";
  339. import Z404 from "../404.vue";
  340. import FloatingBox from "../../components/ui/FloatingBox.vue";
  341. import AddToPlaylistDropdown from "./components/AddToPlaylistDropdown.vue";
  342. import io from "../../io";
  343. import keyboardShortcuts from "../../keyboardShortcuts";
  344. import utils from "../../../js/utils";
  345. import CurrentlyPlaying from "./components/CurrentlyPlaying.vue";
  346. import StationSidebar from "./components/Sidebar/index.vue";
  347. export default {
  348. components: {
  349. MainHeader,
  350. MainFooter,
  351. SongQueue: () => import("./AddSongToQueue.vue"),
  352. EditPlaylist: () => import("../../components/modals/EditPlaylist.vue"),
  353. CreatePlaylist: () =>
  354. import("../../components/modals/CreatePlaylist.vue"),
  355. EditStation: () => import("../../components/modals/EditStation.vue"),
  356. Report: () => import("./Report.vue"),
  357. Z404,
  358. FloatingBox,
  359. CurrentlyPlaying,
  360. StationSidebar,
  361. AddToPlaylistDropdown
  362. },
  363. data() {
  364. return {
  365. utils,
  366. title: "Station",
  367. loading: true,
  368. ready: false,
  369. exists: true,
  370. playerReady: false,
  371. player: undefined,
  372. timePaused: 0,
  373. muted: false,
  374. timeElapsed: "0:00",
  375. liked: false,
  376. disliked: false,
  377. timeBeforePause: 0,
  378. skipVotes: 0,
  379. automaticallyRequestedSongId: null,
  380. systemDifference: 0,
  381. attemptsToPlayVideo: 0,
  382. canAutoplay: true,
  383. lastTimeRequestedIfCanAutoplay: 0,
  384. seeking: false,
  385. playbackRate: 1,
  386. volumeSliderValue: 0,
  387. favoriteStation: false,
  388. showPlaylistDropdown: false
  389. };
  390. },
  391. computed: {
  392. ...mapState("modals", {
  393. modals: state => state.modals.station
  394. }),
  395. ...mapState("station", {
  396. station: state => state.station,
  397. currentSong: state => state.currentSong,
  398. songsList: state => state.songsList,
  399. stationPaused: state => state.stationPaused,
  400. localPaused: state => state.localPaused,
  401. noSong: state => state.noSong,
  402. privatePlaylistQueueSelected: state =>
  403. state.privatePlaylistQueueSelected
  404. }),
  405. ...mapState({
  406. loggedIn: state => state.user.auth.loggedIn,
  407. userId: state => state.user.auth.userId,
  408. role: state => state.user.auth.role
  409. })
  410. },
  411. mounted() {
  412. window.scrollTo(0, 0);
  413. Date.currently = () => {
  414. return new Date().getTime() + this.systemDifference;
  415. };
  416. this.stationName = this.$route.params.id;
  417. window.stationInterval = 0;
  418. io.getSocket(socket => {
  419. this.socket = socket;
  420. io.removeAllListeners();
  421. if (this.socket.connected) this.join();
  422. io.onConnect(this.join);
  423. this.socket.emit("stations.existsByName", this.stationName, res => {
  424. if (res.status === "failure" || !res.exists) {
  425. this.loading = false;
  426. this.exists = false;
  427. }
  428. });
  429. this.socket.on("event:songs.next", data => {
  430. const previousSong = this.currentSong.songId
  431. ? this.currentSong
  432. : null;
  433. this.updatePreviousSong(previousSong);
  434. const { currentSong } = data;
  435. if (currentSong && !currentSong.thumbnail)
  436. currentSong.ytThumbnail = `https://img.youtube.com/vi/${currentSong.songId}/mqdefault.jpg`;
  437. this.updateCurrentSong(currentSong || {});
  438. this.startedAt = data.startedAt;
  439. this.updateStationPaused(data.paused);
  440. this.timePaused = data.timePaused;
  441. if (currentSong) {
  442. this.updateNoSong(false);
  443. if (this.currentSong.artists)
  444. this.currentSong.artists = this.currentSong.artists.join(
  445. ", "
  446. );
  447. if (!this.playerReady) this.youtubeReady();
  448. else this.playVideo();
  449. this.socket.emit(
  450. "songs.getOwnSongRatings",
  451. data.currentSong.songId,
  452. song => {
  453. if (this.currentSong.songId === song.songId) {
  454. this.liked = song.liked;
  455. this.disliked = song.disliked;
  456. if (song.disliked === true)
  457. this.voteSkipStation();
  458. }
  459. }
  460. );
  461. } else {
  462. if (this.playerReady) this.player.pauseVideo();
  463. this.updateNoSong(true);
  464. }
  465. let isInQueue = false;
  466. this.songsList.forEach(queueSong => {
  467. if (queueSong.requestedBy === this.userId) isInQueue = true;
  468. });
  469. if (
  470. !isInQueue &&
  471. this.privatePlaylistQueueSelected &&
  472. (this.automaticallyRequestedSongId !==
  473. this.currentSong.songId ||
  474. !this.currentSong.songId)
  475. ) {
  476. this.addFirstPrivatePlaylistSongToQueue();
  477. }
  478. });
  479. this.socket.on("event:stations.pause", data => {
  480. this.pausedAt = data.pausedAt;
  481. this.updateStationPaused(true);
  482. this.pauseLocalPlayer();
  483. });
  484. this.socket.on("event:stations.resume", data => {
  485. this.timePaused = data.timePaused;
  486. this.updateStationPaused(false);
  487. if (!this.localPaused) this.resumeLocalPlayer();
  488. });
  489. this.socket.on("event:stations.remove", () => {
  490. window.location.href = "/";
  491. return true;
  492. });
  493. this.socket.on("event:song.like", data => {
  494. if (!this.noSong) {
  495. if (data.songId === this.currentSong.songId) {
  496. this.currentSong.dislikes = data.dislikes;
  497. this.currentSong.likes = data.likes;
  498. }
  499. }
  500. });
  501. this.socket.on("event:song.dislike", data => {
  502. if (!this.noSong) {
  503. if (data.songId === this.currentSong.songId) {
  504. this.currentSong.dislikes = data.dislikes;
  505. this.currentSong.likes = data.likes;
  506. }
  507. }
  508. });
  509. this.socket.on("event:song.unlike", data => {
  510. if (!this.noSong) {
  511. if (data.songId === this.currentSong.songId) {
  512. this.currentSong.dislikes = data.dislikes;
  513. this.currentSong.likes = data.likes;
  514. }
  515. }
  516. });
  517. this.socket.on("event:song.undislike", data => {
  518. if (!this.noSong) {
  519. if (data.songId === this.currentSong.songId) {
  520. this.currentSong.dislikes = data.dislikes;
  521. this.currentSong.likes = data.likes;
  522. }
  523. }
  524. });
  525. this.socket.on("event:song.newRatings", data => {
  526. if (!this.noSong) {
  527. if (data.songId === this.currentSong.songId) {
  528. this.liked = data.liked;
  529. this.disliked = data.disliked;
  530. }
  531. }
  532. });
  533. this.socket.on("event:queue.update", queue => {
  534. if (this.station.type === "community")
  535. this.updateSongsList(queue);
  536. });
  537. this.socket.on("event:song.voteSkipSong", () => {
  538. if (this.currentSong) this.currentSong.skipVotes += 1;
  539. });
  540. this.socket.on("event:privatePlaylist.selected", playlistId => {
  541. if (this.station.type === "community") {
  542. this.station.privatePlaylist = playlistId;
  543. }
  544. });
  545. this.socket.on("event:partyMode.updated", partyMode => {
  546. if (this.station.type === "community") {
  547. this.station.partyMode = partyMode;
  548. }
  549. });
  550. this.socket.on("event:newOfficialPlaylist", playlist => {
  551. if (this.station.type === "official") {
  552. this.updateSongsList(playlist);
  553. }
  554. });
  555. this.socket.on("event:users.updated", users => {
  556. this.updateUsers(users);
  557. });
  558. this.socket.on("event:userCount.updated", userCount => {
  559. this.updateUserCount(userCount);
  560. });
  561. this.socket.on("event:queueLockToggled", locked => {
  562. this.station.locked = locked;
  563. });
  564. this.socket.on("event:user.favoritedStation", stationId => {
  565. if (stationId === this.station._id) this.favoriteStation = true;
  566. });
  567. this.socket.on("event:user.unfavoritedStation", stationId => {
  568. if (stationId === this.station._id)
  569. this.favoriteStation = false;
  570. });
  571. });
  572. if (JSON.parse(localStorage.getItem("muted"))) {
  573. this.muted = true;
  574. this.player.setVolume(0);
  575. this.volumeSliderValue = 0 * 100;
  576. } else {
  577. let volume = parseFloat(localStorage.getItem("volume"));
  578. volume =
  579. typeof volume === "number" && !Number.isNaN(volume)
  580. ? volume
  581. : 20;
  582. localStorage.setItem("volume", volume);
  583. this.volumeSliderValue = volume * 100;
  584. }
  585. },
  586. beforeDestroy() {
  587. const shortcutNames = [
  588. "station.pauseResume",
  589. "station.skipStation",
  590. "station.lowerVolumeLarge",
  591. "station.lowerVolumeSmall",
  592. "station.increaseVolumeLarge",
  593. "station.increaseVolumeSmall",
  594. "station.toggleDebug"
  595. ];
  596. shortcutNames.forEach(shortcutName => {
  597. keyboardShortcuts.unregisterShortcut(shortcutName);
  598. });
  599. },
  600. methods: {
  601. isOwnerOnly() {
  602. return this.loggedIn && this.userId === this.station.owner;
  603. },
  604. isAdminOnly() {
  605. return this.loggedIn && this.role === "admin";
  606. },
  607. isOwnerOrAdmin() {
  608. return this.isOwnerOnly() || this.isAdminOnly();
  609. },
  610. openSettings() {
  611. this.editStation({
  612. _id: this.station._id,
  613. name: this.station.name,
  614. type: this.station.type,
  615. partyMode: this.station.partyMode,
  616. description: this.station.description,
  617. privacy: this.station.privacy,
  618. displayName: this.station.displayName,
  619. locked: this.station.locked,
  620. genres: this.station.genres,
  621. blacklistedGenres: this.station.blacklistedGenres
  622. });
  623. this.openModal({
  624. sector: "station",
  625. modal: "editStation"
  626. });
  627. },
  628. removeFromQueue(songId) {
  629. window.socket.emit(
  630. "stations.removeFromQueue",
  631. this.station._id,
  632. songId,
  633. res => {
  634. if (res.status === "success") {
  635. new Toast({
  636. content:
  637. "Successfully removed song from the queue.",
  638. timeout: 4000
  639. });
  640. } else new Toast({ content: res.message, timeout: 8000 });
  641. }
  642. );
  643. },
  644. youtubeReady() {
  645. if (!this.player) {
  646. this.player = new window.YT.Player("player", {
  647. height: 270,
  648. width: 480,
  649. videoId: this.currentSong.songId,
  650. host: "https://www.youtube-nocookie.com",
  651. startSeconds:
  652. this.getTimeElapsed() / 1000 +
  653. this.currentSong.skipDuration,
  654. playerVars: {
  655. controls: 0,
  656. iv_load_policy: 3,
  657. rel: 0,
  658. showinfo: 0
  659. },
  660. events: {
  661. onReady: () => {
  662. this.playerReady = true;
  663. let volume = parseInt(
  664. localStorage.getItem("volume")
  665. );
  666. volume = typeof volume === "number" ? volume : 20;
  667. this.player.setVolume(volume);
  668. if (volume > 0) {
  669. this.player.unMute();
  670. }
  671. if (this.muted) this.player.mute();
  672. this.playVideo();
  673. },
  674. onError: err => {
  675. console.log("iframe error", err);
  676. if (this.loggedIn) this.voteSkipStation();
  677. },
  678. onStateChange: event => {
  679. if (
  680. event.data === window.YT.PlayerState.PLAYING &&
  681. this.videoLoading === true
  682. ) {
  683. this.videoLoading = false;
  684. this.player.seekTo(
  685. this.getTimeElapsed() / 1000 +
  686. this.currentSong.skipDuration,
  687. true
  688. );
  689. if (this.localPaused || this.stationPaused)
  690. this.player.pauseVideo();
  691. } else if (
  692. event.data === window.YT.PlayerState.PLAYING &&
  693. (this.localPaused || this.stationPaused)
  694. ) {
  695. this.player.seekTo(
  696. this.timeBeforePause / 1000,
  697. true
  698. );
  699. this.player.pauseVideo();
  700. } else if (
  701. event.data === window.YT.PlayerState.PLAYING &&
  702. this.seeking === true
  703. ) {
  704. this.seeking = false;
  705. }
  706. if (
  707. event.data === window.YT.PlayerState.PAUSED &&
  708. !this.localPaused &&
  709. !this.stationPaused &&
  710. !this.noSong &&
  711. this.player.getDuration() / 1000 <
  712. this.currentSong.duration
  713. ) {
  714. this.player.seekTo(
  715. this.getTimeElapsed() / 1000 +
  716. this.currentSong.skipDuration,
  717. true
  718. );
  719. this.player.playVideo();
  720. }
  721. }
  722. }
  723. });
  724. }
  725. },
  726. getTimeElapsed() {
  727. if (this.currentSong) {
  728. let { timePaused } = this;
  729. if (this.stationPaused)
  730. timePaused += Date.currently() - this.pausedAt;
  731. return Date.currently() - this.startedAt - timePaused;
  732. }
  733. return 0;
  734. },
  735. playVideo() {
  736. if (this.playerReady) {
  737. this.videoLoading = true;
  738. this.player.loadVideoById(
  739. this.currentSong.songId,
  740. this.getTimeElapsed() / 1000 + this.currentSong.skipDuration
  741. );
  742. if (window.stationInterval !== 0)
  743. clearInterval(window.stationInterval);
  744. window.stationInterval = setInterval(() => {
  745. this.resizeSeekerbar();
  746. this.calculateTimeElapsed();
  747. }, 150);
  748. }
  749. },
  750. resizeSeekerbar() {
  751. if (!this.stationPaused) {
  752. document.getElementById(
  753. "seeker-bar"
  754. ).style.width = `${parseFloat(
  755. (this.getTimeElapsed() / 1000 / this.currentSong.duration) *
  756. 100
  757. )}%`;
  758. }
  759. },
  760. calculateTimeElapsed() {
  761. if (
  762. this.playerReady &&
  763. this.currentSong &&
  764. this.player.getPlayerState() === -1
  765. ) {
  766. if (this.attemptsToPlayVideo >= 5) {
  767. if (
  768. Date.now() - this.lastTimeRequestedIfCanAutoplay >
  769. 2000
  770. ) {
  771. this.lastTimeRequestedIfCanAutoplay = Date.now();
  772. window.canAutoplay.video().then(({ result }) => {
  773. if (result) {
  774. this.attemptsToPlayVideo = 0;
  775. this.canAutoplay = true;
  776. } else {
  777. this.canAutoplay = false;
  778. }
  779. });
  780. }
  781. } else {
  782. this.player.playVideo();
  783. this.attemptsToPlayVideo += 1;
  784. }
  785. }
  786. if (!this.stationPaused && !this.localPaused) {
  787. const timeElapsed = this.getTimeElapsed();
  788. const currentPlayerTime =
  789. Math.max(
  790. this.player.getCurrentTime() -
  791. this.currentSong.skipDuration,
  792. 0
  793. ) * 1000;
  794. const difference = timeElapsed - currentPlayerTime;
  795. // console.log(difference);
  796. let playbackRate = 1;
  797. if (difference < -2000) {
  798. if (!this.seeking) {
  799. this.seeking = true;
  800. this.player.seekTo(
  801. this.getTimeElapsed() / 1000 +
  802. this.currentSong.skipDuration
  803. );
  804. }
  805. } else if (difference < -200) {
  806. // console.log("Difference0.8");
  807. playbackRate = 0.8;
  808. } else if (difference < -50) {
  809. // console.log("Difference0.9");
  810. playbackRate = 0.9;
  811. } else if (difference < -25) {
  812. // console.log("Difference0.99");
  813. playbackRate = 0.95;
  814. } else if (difference > 2000) {
  815. if (!this.seeking) {
  816. this.seeking = true;
  817. this.player.seekTo(
  818. this.getTimeElapsed() / 1000 +
  819. this.currentSong.skipDuration
  820. );
  821. }
  822. } else if (difference > 200) {
  823. // console.log("Difference1.2");
  824. playbackRate = 1.2;
  825. } else if (difference > 50) {
  826. // console.log("Difference1.1");
  827. playbackRate = 1.1;
  828. } else if (difference > 25) {
  829. // console.log("Difference1.01");
  830. playbackRate = 1.05;
  831. } else if (this.player.getPlaybackRate !== 1.0) {
  832. // console.log("NDifference1.0");
  833. this.player.setPlaybackRate(1.0);
  834. }
  835. if (this.playbackRate !== playbackRate) {
  836. this.player.setPlaybackRate(playbackRate);
  837. this.playbackRate = playbackRate;
  838. }
  839. }
  840. /* if (this.currentTime !== undefined && this.paused) {
  841. this.timePaused += Date.currently() - this.currentTime;
  842. this.currentTime = undefined;
  843. } */
  844. let { timePaused } = this;
  845. if (this.stationPaused)
  846. timePaused += Date.currently() - this.pausedAt;
  847. const duration =
  848. (Date.currently() - this.startedAt - timePaused) / 1000;
  849. const songDuration = this.currentSong.duration;
  850. if (songDuration <= duration) this.player.pauseVideo();
  851. if (!this.stationPaused && duration <= songDuration)
  852. this.timeElapsed = utils.formatTime(duration);
  853. },
  854. toggleLock() {
  855. window.socket.emit("stations.toggleLock", this.station._id, res => {
  856. if (res.status === "success") {
  857. new Toast({
  858. content: "Successfully toggled the queue lock.",
  859. timeout: 4000
  860. });
  861. } else new Toast({ content: res.message, timeout: 8000 });
  862. });
  863. },
  864. changeVolume() {
  865. const volume = this.volumeSliderValue;
  866. localStorage.setItem("volume", volume / 100);
  867. if (this.playerReady) {
  868. this.player.setVolume(volume / 100);
  869. if (volume > 0) {
  870. this.player.unMute();
  871. localStorage.setItem("muted", false);
  872. this.muted = false;
  873. }
  874. }
  875. },
  876. resumeLocalStation() {
  877. this.updateLocalPaused(false);
  878. if (!this.stationPaused) this.resumeLocalPlayer();
  879. },
  880. pauseLocalStation() {
  881. this.updateLocalPaused(true);
  882. this.pauseLocalPlayer();
  883. },
  884. resumeLocalPlayer() {
  885. if (!this.noSong) {
  886. if (this.playerReady) {
  887. this.player.seekTo(
  888. this.getTimeElapsed() / 1000 +
  889. this.currentSong.skipDuration
  890. );
  891. this.player.playVideo();
  892. }
  893. }
  894. },
  895. pauseLocalPlayer() {
  896. if (!this.noSong) {
  897. this.timeBeforePause = this.getTimeElapsed();
  898. if (this.playerReady) this.player.pauseVideo();
  899. }
  900. },
  901. skipStation() {
  902. this.socket.emit("stations.forceSkip", this.station._id, data => {
  903. if (data.status !== "success")
  904. new Toast({
  905. content: `Error: ${data.message}`,
  906. timeout: 8000
  907. });
  908. else
  909. new Toast({
  910. content:
  911. "Successfully skipped the station's current song.",
  912. timeout: 4000
  913. });
  914. });
  915. },
  916. voteSkipStation() {
  917. this.socket.emit("stations.voteSkip", this.station._id, data => {
  918. if (data.status !== "success")
  919. new Toast({
  920. content: `Error: ${data.message}`,
  921. timeout: 8000
  922. });
  923. else
  924. new Toast({
  925. content: "Successfully voted to skip the current song.",
  926. timeout: 4000
  927. });
  928. });
  929. },
  930. resumeStation() {
  931. this.socket.emit("stations.resume", this.station._id, data => {
  932. if (data.status !== "success")
  933. new Toast({
  934. content: `Error: ${data.message}`,
  935. timeout: 8000
  936. });
  937. else
  938. new Toast({
  939. content: "Successfully resumed the station.",
  940. timeout: 4000
  941. });
  942. });
  943. },
  944. pauseStation() {
  945. this.socket.emit("stations.pause", this.station._id, data => {
  946. if (data.status !== "success")
  947. new Toast({
  948. content: `Error: ${data.message}`,
  949. timeout: 8000
  950. });
  951. else
  952. new Toast({
  953. content: "Successfully paused the station.",
  954. timeout: 4000
  955. });
  956. });
  957. },
  958. toggleMute() {
  959. if (this.playerReady) {
  960. const previousVolume = parseFloat(
  961. localStorage.getItem("volume")
  962. );
  963. const volume =
  964. this.player.getVolume() * 100 <= 0 ? previousVolume : 0;
  965. this.muted = !this.muted;
  966. localStorage.setItem("muted", this.muted);
  967. this.volumeSliderValue = volume * 100;
  968. this.player.setVolume(volume);
  969. if (!this.muted) localStorage.setItem("volume", volume);
  970. }
  971. },
  972. increaseVolume() {
  973. if (this.playerReady) {
  974. const previousVolume = parseInt(localStorage.getItem("volume"));
  975. let volume = previousVolume + 5;
  976. if (previousVolume === 0) {
  977. this.muted = false;
  978. localStorage.setItem("muted", false);
  979. }
  980. if (volume > 100) volume = 100;
  981. this.volumeSliderValue = volume * 100;
  982. this.player.setVolume(volume);
  983. localStorage.setItem("volume", volume);
  984. }
  985. },
  986. toggleLike() {
  987. if (this.liked)
  988. this.socket.emit(
  989. "songs.unlike",
  990. this.currentSong.songId,
  991. data => {
  992. if (data.status !== "success")
  993. new Toast({
  994. content: `Error: ${data.message}`,
  995. timeout: 8000
  996. });
  997. }
  998. );
  999. else
  1000. this.socket.emit(
  1001. "songs.like",
  1002. this.currentSong.songId,
  1003. data => {
  1004. if (data.status !== "success")
  1005. new Toast({
  1006. content: `Error: ${data.message}`,
  1007. timeout: 8000
  1008. });
  1009. }
  1010. );
  1011. },
  1012. toggleDislike() {
  1013. if (this.disliked)
  1014. return this.socket.emit(
  1015. "songs.undislike",
  1016. this.currentSong.songId,
  1017. data => {
  1018. if (data.status !== "success")
  1019. new Toast({
  1020. content: `Error: ${data.message}`,
  1021. timeout: 8000
  1022. });
  1023. }
  1024. );
  1025. return this.socket.emit(
  1026. "songs.dislike",
  1027. this.currentSong.songId,
  1028. data => {
  1029. if (data.status !== "success")
  1030. new Toast({
  1031. content: `Error: ${data.message}`,
  1032. timeout: 8000
  1033. });
  1034. }
  1035. );
  1036. },
  1037. addFirstPrivatePlaylistSongToQueue() {
  1038. let isInQueue = false;
  1039. if (
  1040. this.station.type === "community" &&
  1041. this.station.partyMode === true
  1042. ) {
  1043. this.songsList.forEach(queueSong => {
  1044. if (queueSong.requestedBy === this.userId) isInQueue = true;
  1045. });
  1046. if (!isInQueue && this.privatePlaylistQueueSelected) {
  1047. this.socket.emit(
  1048. "playlists.getFirstSong",
  1049. this.privatePlaylistQueueSelected,
  1050. data => {
  1051. if (data.status === "success") {
  1052. if (data.song) {
  1053. if (data.song.duration < 15 * 60) {
  1054. this.automaticallyRequestedSongId =
  1055. data.song.songId;
  1056. this.socket.emit(
  1057. "stations.addToQueue",
  1058. this.station._id,
  1059. data.song.songId,
  1060. data2 => {
  1061. if (
  1062. data2.status === "success"
  1063. ) {
  1064. this.socket.emit(
  1065. "playlists.moveSongToBottom",
  1066. this
  1067. .privatePlaylistQueueSelected,
  1068. data.song.songId,
  1069. data3 => {
  1070. if (
  1071. data3.status ===
  1072. "success"
  1073. ) {
  1074. console.log(
  1075. "This comment is just here because of eslint/prettier issues, ignore it"
  1076. );
  1077. }
  1078. }
  1079. );
  1080. }
  1081. }
  1082. );
  1083. } else {
  1084. new Toast({
  1085. content: `Top song in playlist was too long to be added.`,
  1086. timeout: 3000
  1087. });
  1088. this.socket.emit(
  1089. "playlists.moveSongToBottom",
  1090. this.privatePlaylistQueueSelected,
  1091. data.song.songId,
  1092. data3 => {
  1093. if (
  1094. data3.status === "success"
  1095. ) {
  1096. setTimeout(() => {
  1097. this.addFirstPrivatePlaylistSongToQueue();
  1098. }, 3000);
  1099. }
  1100. }
  1101. );
  1102. }
  1103. } else {
  1104. new Toast({
  1105. content: `Selected playlist has no songs.`,
  1106. timeout: 4000
  1107. });
  1108. }
  1109. }
  1110. }
  1111. );
  1112. }
  1113. }
  1114. },
  1115. togglePlayerDebugBox() {
  1116. this.$refs.playerDebugBox.toggleBox();
  1117. },
  1118. resetPlayerDebugBox() {
  1119. this.$refs.playerDebugBox.resetBox();
  1120. },
  1121. join() {
  1122. this.socket.emit("stations.join", this.stationName, res => {
  1123. if (res.status === "success") {
  1124. this.loading = false;
  1125. const {
  1126. _id,
  1127. displayName,
  1128. description,
  1129. privacy,
  1130. locked,
  1131. partyMode,
  1132. owner,
  1133. privatePlaylist,
  1134. type,
  1135. genres,
  1136. blacklistedGenres
  1137. } = res.data;
  1138. this.joinStation({
  1139. _id,
  1140. name: this.stationName,
  1141. displayName,
  1142. description,
  1143. privacy,
  1144. locked,
  1145. partyMode,
  1146. owner,
  1147. privatePlaylist,
  1148. type,
  1149. genres,
  1150. blacklistedGenres
  1151. });
  1152. const currentSong = res.data.currentSong
  1153. ? res.data.currentSong
  1154. : {};
  1155. if (currentSong.artists)
  1156. currentSong.artists = currentSong.artists.join(", ");
  1157. if (currentSong && !currentSong.thumbnail)
  1158. currentSong.ytThumbnail = `https://img.youtube.com/vi/${currentSong.songId}/mqdefault.jpg`;
  1159. this.updateCurrentSong(currentSong);
  1160. this.startedAt = res.data.startedAt;
  1161. this.updateStationPaused(res.data.paused);
  1162. this.timePaused = res.data.timePaused;
  1163. this.updateUserCount(res.data.userCount);
  1164. this.updateUsers(res.data.users);
  1165. this.pausedAt = res.data.pausedAt;
  1166. if (res.data.currentSong) {
  1167. this.updateNoSong(false);
  1168. this.youtubeReady();
  1169. this.playVideo();
  1170. this.socket.emit(
  1171. "songs.getOwnSongRatings",
  1172. res.data.currentSong.songId,
  1173. data => {
  1174. if (this.currentSong.songId === data.songId) {
  1175. this.liked = data.liked;
  1176. this.disliked = data.disliked;
  1177. }
  1178. }
  1179. );
  1180. } else {
  1181. if (this.playerReady) this.player.pauseVideo();
  1182. this.updateNoSong(true);
  1183. }
  1184. if (type === "community" && partyMode === true) {
  1185. this.socket.emit("stations.getQueue", _id, res => {
  1186. if (res.status === "success") {
  1187. this.updateSongsList(res.queue);
  1188. }
  1189. });
  1190. }
  1191. if (this.isOwnerOrAdmin()) {
  1192. keyboardShortcuts.registerShortcut(
  1193. "station.pauseResume",
  1194. {
  1195. keyCode: 32,
  1196. shift: false,
  1197. ctrl: true,
  1198. preventDefault: true,
  1199. handler: () => {
  1200. if (this.stationPaused)
  1201. this.resumeStation();
  1202. else this.pauseStation();
  1203. }
  1204. }
  1205. );
  1206. keyboardShortcuts.registerShortcut(
  1207. "station.skipStation",
  1208. {
  1209. keyCode: 39,
  1210. shift: false,
  1211. ctrl: true,
  1212. preventDefault: true,
  1213. handler: () => {
  1214. this.skipStation();
  1215. }
  1216. }
  1217. );
  1218. }
  1219. keyboardShortcuts.registerShortcut(
  1220. "station.lowerVolumeLarge",
  1221. {
  1222. keyCode: 40,
  1223. shift: false,
  1224. ctrl: true,
  1225. preventDefault: true,
  1226. handler: () => {
  1227. this.volumeSliderValue -= 1000;
  1228. this.changeVolume();
  1229. }
  1230. }
  1231. );
  1232. keyboardShortcuts.registerShortcut(
  1233. "station.lowerVolumeSmall",
  1234. {
  1235. keyCode: 40,
  1236. shift: true,
  1237. ctrl: true,
  1238. preventDefault: true,
  1239. handler: () => {
  1240. this.volumeSliderValue -= 100;
  1241. this.changeVolume();
  1242. }
  1243. }
  1244. );
  1245. keyboardShortcuts.registerShortcut(
  1246. "station.increaseVolumeLarge",
  1247. {
  1248. keyCode: 38,
  1249. shift: false,
  1250. ctrl: true,
  1251. preventDefault: true,
  1252. handler: () => {
  1253. this.volumeSliderValue += 1000;
  1254. this.changeVolume();
  1255. }
  1256. }
  1257. );
  1258. keyboardShortcuts.registerShortcut(
  1259. "station.increaseVolumeSmall",
  1260. {
  1261. keyCode: 38,
  1262. shift: true,
  1263. ctrl: true,
  1264. preventDefault: true,
  1265. handler: () => {
  1266. this.volumeSliderValue += 100;
  1267. this.changeVolume();
  1268. }
  1269. }
  1270. );
  1271. keyboardShortcuts.registerShortcut("station.toggleDebug", {
  1272. keyCode: 68,
  1273. shift: false,
  1274. ctrl: true,
  1275. preventDefault: true,
  1276. handler: () => {
  1277. this.togglePlayerDebugBox();
  1278. }
  1279. });
  1280. // UNIX client time before ping
  1281. const beforePing = Date.now();
  1282. this.socket.emit("apis.ping", pong => {
  1283. // UNIX client time after ping
  1284. const afterPing = Date.now();
  1285. // Average time in MS it took between the server responding and the client receiving
  1286. const connectionLatency = (afterPing - beforePing) / 2;
  1287. console.log(connectionLatency, beforePing - afterPing);
  1288. // UNIX server time
  1289. const serverDate = pong.date;
  1290. // Difference between the server UNIX time and the client UNIX time after ping, with the connectionLatency added to the server UNIX time
  1291. const difference =
  1292. serverDate + connectionLatency - afterPing;
  1293. console.log("Difference: ", difference);
  1294. if (difference > 3000 || difference < -3000) {
  1295. console.log(
  1296. "System time difference is bigger than 3 seconds."
  1297. );
  1298. }
  1299. this.systemDifference = difference;
  1300. });
  1301. } else {
  1302. this.loading = false;
  1303. this.exists = false;
  1304. }
  1305. });
  1306. this.socket.emit("users.getFavoriteStations", data => {
  1307. if (
  1308. data.status === "success" &&
  1309. data.favoriteStations.indexOf(this.station._id) !== -1
  1310. )
  1311. this.favoriteStation = true;
  1312. });
  1313. },
  1314. addfavoriteStation(event) {
  1315. event.preventDefault();
  1316. this.socket.emit(
  1317. "stations.favoriteStation",
  1318. this.station._id,
  1319. res => {
  1320. if (res.status === "success") {
  1321. new Toast({
  1322. content: "Successfully favorited station.",
  1323. timeout: 4000
  1324. });
  1325. } else new Toast({ content: res.message, timeout: 8000 });
  1326. }
  1327. );
  1328. },
  1329. unfavoriteStation(event) {
  1330. event.preventDefault();
  1331. this.socket.emit(
  1332. "stations.unfavoriteStation",
  1333. this.station._id,
  1334. res => {
  1335. if (res.status === "success") {
  1336. new Toast({
  1337. content: "Successfully unfavorited station.",
  1338. timeout: 4000
  1339. });
  1340. } else new Toast({ content: res.message, timeout: 8000 });
  1341. }
  1342. );
  1343. },
  1344. ...mapActions("modals", ["openModal"]),
  1345. ...mapActions("station", [
  1346. "joinStation",
  1347. "updateUserCount",
  1348. "updateUsers",
  1349. "updateCurrentSong",
  1350. "updatePreviousSong",
  1351. "updateSongsList",
  1352. "updateStationPaused",
  1353. "updateLocalPaused",
  1354. "updateNoSong",
  1355. "editStation"
  1356. ])
  1357. }
  1358. };
  1359. </script>
  1360. <style lang="scss" scoped>
  1361. @import "../../styles/global.scss";
  1362. .main-container {
  1363. min-height: calc(100vh + 100px);
  1364. }
  1365. .progress {
  1366. width: 50px;
  1367. animation: rotate 0.8s infinite linear;
  1368. border: 8px solid $primary-color;
  1369. border-right-color: transparent;
  1370. height: 50px;
  1371. position: absolute;
  1372. top: 50%;
  1373. left: 50%;
  1374. }
  1375. @keyframes rotate {
  1376. 0% {
  1377. transform: rotate(0deg);
  1378. }
  1379. 100% {
  1380. transform: rotate(360deg);
  1381. }
  1382. }
  1383. .experimental {
  1384. display: none !important;
  1385. }
  1386. #player-debug-box {
  1387. .box-body {
  1388. flex-direction: column;
  1389. b {
  1390. color: #000;
  1391. }
  1392. }
  1393. }
  1394. .night-mode {
  1395. #currently-playing-container,
  1396. #about-station-container,
  1397. #control-bar-container,
  1398. .player-container.nothing-here {
  1399. background-color: $night-mode-bg-secondary !important;
  1400. }
  1401. #upper-row .quadrant,
  1402. #video-container,
  1403. #control-bar-container {
  1404. border: 0 !important;
  1405. }
  1406. #dropdown-toggle {
  1407. background-color: $dark-grey !important;
  1408. border: 0;
  1409. i {
  1410. color: #fff;
  1411. }
  1412. }
  1413. }
  1414. #station-outer-container {
  1415. margin: 0 auto;
  1416. max-width: 100%;
  1417. padding: 20px 40px;
  1418. margin-top: 5px;
  1419. height: 100%;
  1420. /** Mobile Row */
  1421. @media (max-width: 1040px) {
  1422. padding: 0;
  1423. margin-top: 0 !important;
  1424. height: auto !important;
  1425. #station-inner-container {
  1426. justify-content: flex-start !important;
  1427. }
  1428. .row {
  1429. width: 100%;
  1430. flex-direction: column !important;
  1431. }
  1432. .quadrant,
  1433. .player-container {
  1434. width: 100% !important;
  1435. border: 0 !important;
  1436. }
  1437. .quadrant,
  1438. .player-container {
  1439. background: transparent !important;
  1440. }
  1441. /** padding fixes on mobile */
  1442. #about-station-container,
  1443. #currently-playing-container {
  1444. padding: 15px 10px !important;
  1445. }
  1446. #about-station-container:not(.nothing-here) {
  1447. padding-bottom: 0 !important;
  1448. }
  1449. #currently-playing {
  1450. padding: 0;
  1451. }
  1452. /** no column gap between quadrants on mobile */
  1453. #currently-playing-container,
  1454. #sidebar-container {
  1455. margin-left: 0 !important;
  1456. }
  1457. #lower-row {
  1458. margin-top: 0 !important;
  1459. }
  1460. /** Change height of YouTube embed */
  1461. .player-container:not(.nothing-here) {
  1462. height: 800px !important;
  1463. }
  1464. .player-container {
  1465. height: 50px;
  1466. }
  1467. /** mainly irrelevant on mobile */
  1468. .no-currently-playing {
  1469. display: none !important;
  1470. }
  1471. }
  1472. #station-inner-container {
  1473. display: flex;
  1474. align-items: center;
  1475. flex-direction: column;
  1476. height: 100%;
  1477. @media (min-height: 1050px) {
  1478. justify-content: center;
  1479. }
  1480. @media (min-width: 1040px) and (max-width: 2100px) {
  1481. #control-bar-container {
  1482. .optional-desktop-only-text {
  1483. display: none;
  1484. }
  1485. .button:not(#dropdown-toggle) {
  1486. width: 75px;
  1487. }
  1488. #add-song-to-playlist .button,
  1489. #local-resume,
  1490. #local-pause {
  1491. i {
  1492. margin-right: 0 !important;
  1493. }
  1494. }
  1495. }
  1496. }
  1497. .row {
  1498. display: flex;
  1499. flex-direction: row;
  1500. max-width: 100%;
  1501. .quadrant {
  1502. display: flex;
  1503. align-items: center;
  1504. justify-content: center;
  1505. flex-direction: column;
  1506. max-width: 100%;
  1507. border-radius: 5px;
  1508. }
  1509. }
  1510. #upper-row {
  1511. .quadrant {
  1512. border: 1px solid $light-grey-2;
  1513. background-color: #fff;
  1514. }
  1515. #about-station-container {
  1516. width: 1400px;
  1517. align-items: flex-start;
  1518. padding: 20px;
  1519. #station-name {
  1520. flex-direction: row !important;
  1521. h1 {
  1522. margin: 0;
  1523. font-size: 36px;
  1524. }
  1525. i {
  1526. margin-left: 10px;
  1527. font-size: 30px;
  1528. color: $yellow;
  1529. }
  1530. }
  1531. p {
  1532. max-width: 700px;
  1533. flex-grow: 1;
  1534. }
  1535. #admin-buttons {
  1536. margin-top: 15px;
  1537. @media (max-width: 450px) {
  1538. .optional-desktop-only-text {
  1539. display: none;
  1540. }
  1541. }
  1542. }
  1543. }
  1544. #currently-playing-container {
  1545. width: 550px;
  1546. margin-left: 50px;
  1547. }
  1548. }
  1549. #lower-row {
  1550. margin-top: 20px;
  1551. height: 90%;
  1552. .player-container.nothing-here {
  1553. border: 1px solid $light-grey-2;
  1554. border-radius: 5px;
  1555. }
  1556. .player-container {
  1557. width: 1400px;
  1558. background-color: #fff;
  1559. display: flex;
  1560. flex-direction: column;
  1561. border: 1px solid $light-grey-2;
  1562. border-radius: 5px;
  1563. overflow: hidden;
  1564. #video-container {
  1565. width: 100%;
  1566. height: 100%;
  1567. .player-cannot-autoplay {
  1568. position: relative;
  1569. width: 100%;
  1570. height: 100%;
  1571. bottom: calc(100% + 5px);
  1572. background: rgba(3, 169, 244, 0.95);
  1573. display: flex;
  1574. align-items: center;
  1575. justify-content: center;
  1576. p {
  1577. color: $white;
  1578. font-size: 26px;
  1579. text-align: center;
  1580. }
  1581. }
  1582. }
  1583. #seeker-bar-container {
  1584. background-color: #fff;
  1585. position: relative;
  1586. height: 7px;
  1587. display: block;
  1588. width: 100%;
  1589. overflow: hidden;
  1590. #seeker-bar {
  1591. background-color: $musare-blue;
  1592. top: 0;
  1593. left: 0;
  1594. bottom: 0;
  1595. position: absolute;
  1596. }
  1597. }
  1598. #control-bar-container {
  1599. display: flex;
  1600. justify-content: space-around;
  1601. padding: 10px 0;
  1602. width: 100%;
  1603. background: #fff;
  1604. flex-direction: column;
  1605. flex-flow: wrap;
  1606. #left-buttons,
  1607. #right-buttons {
  1608. margin: 3px;
  1609. i {
  1610. margin-right: 3px;
  1611. }
  1612. }
  1613. #left-buttons {
  1614. display: flex;
  1615. .button:not(:first-of-type) {
  1616. margin-left: 5px;
  1617. }
  1618. }
  1619. #duration {
  1620. margin: 3px;
  1621. display: flex;
  1622. align-items: center;
  1623. p {
  1624. font-size: 22px;
  1625. /** prevents duration width slightly varying and shifting other controls slightly */
  1626. width: 125px;
  1627. text-align: center;
  1628. }
  1629. }
  1630. #volume-control {
  1631. margin: 3px;
  1632. margin-top: 0;
  1633. position: relative;
  1634. display: flex;
  1635. align-items: center;
  1636. cursor: pointer;
  1637. .volume-slider {
  1638. width: 500px;
  1639. padding: 0 15px;
  1640. background: transparent;
  1641. @media (max-width: 2150px) {
  1642. width: 250px !important;
  1643. }
  1644. }
  1645. input[type="range"] {
  1646. -webkit-appearance: none;
  1647. margin: 7.3px 0;
  1648. }
  1649. input[type="range"]:focus {
  1650. outline: none;
  1651. }
  1652. input[type="range"]::-webkit-slider-runnable-track {
  1653. width: 100%;
  1654. height: 5.2px;
  1655. cursor: pointer;
  1656. box-shadow: 0;
  1657. background: $light-grey-2;
  1658. border-radius: 0;
  1659. border: 0;
  1660. }
  1661. input[type="range"]::-webkit-slider-thumb {
  1662. box-shadow: 0;
  1663. border: 0;
  1664. height: 19px;
  1665. width: 19px;
  1666. border-radius: 15px;
  1667. background: $primary-color;
  1668. cursor: pointer;
  1669. -webkit-appearance: none;
  1670. margin-top: -6.5px;
  1671. }
  1672. input[type="range"]::-moz-range-track {
  1673. width: 100%;
  1674. height: 5.2px;
  1675. cursor: pointer;
  1676. box-shadow: 0;
  1677. background: $light-grey-2;
  1678. border-radius: 0;
  1679. border: 0;
  1680. }
  1681. input[type="range"]::-moz-range-thumb {
  1682. box-shadow: 0;
  1683. border: 0;
  1684. height: 19px;
  1685. width: 19px;
  1686. border-radius: 15px;
  1687. background: $primary-color;
  1688. cursor: pointer;
  1689. -webkit-appearance: none;
  1690. margin-top: -6.5px;
  1691. }
  1692. input[type="range"]::-ms-track {
  1693. width: 100%;
  1694. height: 5.2px;
  1695. cursor: pointer;
  1696. box-shadow: 0;
  1697. background: $light-grey-2;
  1698. border-radius: 1.3px;
  1699. }
  1700. input[type="range"]::-ms-fill-lower {
  1701. background: $light-grey-2;
  1702. border: 0;
  1703. border-radius: 0;
  1704. box-shadow: 0;
  1705. }
  1706. input[type="range"]::-ms-fill-upper {
  1707. background: $light-grey-2;
  1708. border: 0;
  1709. border-radius: 0;
  1710. box-shadow: 0;
  1711. }
  1712. input[type="range"]::-ms-thumb {
  1713. box-shadow: 0;
  1714. border: 0;
  1715. height: 15px;
  1716. width: 15px;
  1717. border-radius: 15px;
  1718. background: $primary-color;
  1719. cursor: pointer;
  1720. -webkit-appearance: none;
  1721. margin-top: 1.5px;
  1722. }
  1723. }
  1724. #right-buttons {
  1725. display: flex;
  1726. #dropdown-toggle {
  1727. width: 35px;
  1728. }
  1729. #dislike-song,
  1730. #add-song-to-playlist .button:not(#dropdown-toggle) {
  1731. margin-left: 5px;
  1732. }
  1733. #ratings {
  1734. display: flex;
  1735. #like-song:hover,
  1736. #like-song.liked {
  1737. background-color: darken($green, 5%) !important;
  1738. }
  1739. #dislike-song:hover,
  1740. #dislike-song.disliked {
  1741. background-color: darken($red, 5%) !important;
  1742. }
  1743. &.liked #dislike-song,
  1744. &.disliked #like-song {
  1745. background-color: $grey !important;
  1746. &:hover {
  1747. background-color: darken(
  1748. $grey,
  1749. 5%
  1750. ) !important;
  1751. }
  1752. }
  1753. }
  1754. #add-song-to-playlist {
  1755. display: flex;
  1756. flex-direction: column-reverse;
  1757. align-items: center;
  1758. width: 212px;
  1759. .control {
  1760. width: fit-content;
  1761. margin-bottom: 0 !important;
  1762. }
  1763. }
  1764. }
  1765. }
  1766. }
  1767. #sidebar-container {
  1768. position: relative;
  1769. width: 550px;
  1770. height: inherit;
  1771. margin-left: 50px;
  1772. }
  1773. }
  1774. }
  1775. }
  1776. /deep/ .nothing-here {
  1777. display: flex;
  1778. align-items: center;
  1779. justify-content: center;
  1780. text-transform: uppercase;
  1781. }
  1782. </style>