index.vue 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941
  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. });
  621. this.openModal({
  622. sector: "station",
  623. modal: "editStation"
  624. });
  625. },
  626. removeFromQueue(songId) {
  627. window.socket.emit(
  628. "stations.removeFromQueue",
  629. this.station._id,
  630. songId,
  631. res => {
  632. if (res.status === "success") {
  633. new Toast({
  634. content:
  635. "Successfully removed song from the queue.",
  636. timeout: 4000
  637. });
  638. } else new Toast({ content: res.message, timeout: 8000 });
  639. }
  640. );
  641. },
  642. youtubeReady() {
  643. if (!this.player) {
  644. this.player = new window.YT.Player("player", {
  645. height: 270,
  646. width: 480,
  647. videoId: this.currentSong.songId,
  648. host: "https://www.youtube-nocookie.com",
  649. startSeconds:
  650. this.getTimeElapsed() / 1000 +
  651. this.currentSong.skipDuration,
  652. playerVars: {
  653. controls: 0,
  654. iv_load_policy: 3,
  655. rel: 0,
  656. showinfo: 0
  657. },
  658. events: {
  659. onReady: () => {
  660. this.playerReady = true;
  661. let volume = parseInt(
  662. localStorage.getItem("volume")
  663. );
  664. volume = typeof volume === "number" ? volume : 20;
  665. this.player.setVolume(volume);
  666. if (volume > 0) {
  667. this.player.unMute();
  668. }
  669. if (this.muted) this.player.mute();
  670. this.playVideo();
  671. },
  672. onError: err => {
  673. console.log("iframe error", err);
  674. if (this.loggedIn) this.voteSkipStation();
  675. },
  676. onStateChange: event => {
  677. if (
  678. event.data === window.YT.PlayerState.PLAYING &&
  679. this.videoLoading === true
  680. ) {
  681. this.videoLoading = false;
  682. this.player.seekTo(
  683. this.getTimeElapsed() / 1000 +
  684. this.currentSong.skipDuration,
  685. true
  686. );
  687. if (this.localPaused || this.stationPaused)
  688. this.player.pauseVideo();
  689. } else if (
  690. event.data === window.YT.PlayerState.PLAYING &&
  691. (this.localPaused || this.stationPaused)
  692. ) {
  693. this.player.seekTo(
  694. this.timeBeforePause / 1000,
  695. true
  696. );
  697. this.player.pauseVideo();
  698. } else if (
  699. event.data === window.YT.PlayerState.PLAYING &&
  700. this.seeking === true
  701. ) {
  702. this.seeking = false;
  703. }
  704. if (
  705. event.data === window.YT.PlayerState.PAUSED &&
  706. !this.localPaused &&
  707. !this.stationPaused &&
  708. !this.noSong &&
  709. this.player.getDuration() / 1000 <
  710. this.currentSong.duration
  711. ) {
  712. this.player.seekTo(
  713. this.getTimeElapsed() / 1000 +
  714. this.currentSong.skipDuration,
  715. true
  716. );
  717. this.player.playVideo();
  718. }
  719. }
  720. }
  721. });
  722. }
  723. },
  724. getTimeElapsed() {
  725. if (this.currentSong) {
  726. let { timePaused } = this;
  727. if (this.stationPaused)
  728. timePaused += Date.currently() - this.pausedAt;
  729. return Date.currently() - this.startedAt - timePaused;
  730. }
  731. return 0;
  732. },
  733. playVideo() {
  734. if (this.playerReady) {
  735. this.videoLoading = true;
  736. this.player.loadVideoById(
  737. this.currentSong.songId,
  738. this.getTimeElapsed() / 1000 + this.currentSong.skipDuration
  739. );
  740. if (window.stationInterval !== 0)
  741. clearInterval(window.stationInterval);
  742. window.stationInterval = setInterval(() => {
  743. this.resizeSeekerbar();
  744. this.calculateTimeElapsed();
  745. }, 150);
  746. }
  747. },
  748. resizeSeekerbar() {
  749. if (!this.stationPaused) {
  750. document.getElementById(
  751. "seeker-bar"
  752. ).style.width = `${parseFloat(
  753. (this.getTimeElapsed() / 1000 / this.currentSong.duration) *
  754. 100
  755. )}%`;
  756. }
  757. },
  758. calculateTimeElapsed() {
  759. if (
  760. this.playerReady &&
  761. this.currentSong &&
  762. this.player.getPlayerState() === -1
  763. ) {
  764. if (this.attemptsToPlayVideo >= 5) {
  765. if (
  766. Date.now() - this.lastTimeRequestedIfCanAutoplay >
  767. 2000
  768. ) {
  769. this.lastTimeRequestedIfCanAutoplay = Date.now();
  770. window.canAutoplay.video().then(({ result }) => {
  771. if (result) {
  772. this.attemptsToPlayVideo = 0;
  773. this.canAutoplay = true;
  774. } else {
  775. this.canAutoplay = false;
  776. }
  777. });
  778. }
  779. } else {
  780. this.player.playVideo();
  781. this.attemptsToPlayVideo += 1;
  782. }
  783. }
  784. if (!this.stationPaused && !this.localPaused) {
  785. const timeElapsed = this.getTimeElapsed();
  786. const currentPlayerTime =
  787. Math.max(
  788. this.player.getCurrentTime() -
  789. this.currentSong.skipDuration,
  790. 0
  791. ) * 1000;
  792. const difference = timeElapsed - currentPlayerTime;
  793. // console.log(difference);
  794. let playbackRate = 1;
  795. if (difference < -2000) {
  796. if (!this.seeking) {
  797. this.seeking = true;
  798. this.player.seekTo(
  799. this.getTimeElapsed() / 1000 +
  800. this.currentSong.skipDuration
  801. );
  802. }
  803. } else if (difference < -200) {
  804. // console.log("Difference0.8");
  805. playbackRate = 0.8;
  806. } else if (difference < -50) {
  807. // console.log("Difference0.9");
  808. playbackRate = 0.9;
  809. } else if (difference < -25) {
  810. // console.log("Difference0.99");
  811. playbackRate = 0.95;
  812. } else if (difference > 2000) {
  813. if (!this.seeking) {
  814. this.seeking = true;
  815. this.player.seekTo(
  816. this.getTimeElapsed() / 1000 +
  817. this.currentSong.skipDuration
  818. );
  819. }
  820. } else if (difference > 200) {
  821. // console.log("Difference1.2");
  822. playbackRate = 1.2;
  823. } else if (difference > 50) {
  824. // console.log("Difference1.1");
  825. playbackRate = 1.1;
  826. } else if (difference > 25) {
  827. // console.log("Difference1.01");
  828. playbackRate = 1.05;
  829. } else if (this.player.getPlaybackRate !== 1.0) {
  830. // console.log("NDifference1.0");
  831. this.player.setPlaybackRate(1.0);
  832. }
  833. if (this.playbackRate !== playbackRate) {
  834. this.player.setPlaybackRate(playbackRate);
  835. this.playbackRate = playbackRate;
  836. }
  837. }
  838. /* if (this.currentTime !== undefined && this.paused) {
  839. this.timePaused += Date.currently() - this.currentTime;
  840. this.currentTime = undefined;
  841. } */
  842. let { timePaused } = this;
  843. if (this.stationPaused)
  844. timePaused += Date.currently() - this.pausedAt;
  845. const duration =
  846. (Date.currently() - this.startedAt - timePaused) / 1000;
  847. const songDuration = this.currentSong.duration;
  848. if (songDuration <= duration) this.player.pauseVideo();
  849. if (!this.stationPaused && duration <= songDuration)
  850. this.timeElapsed = utils.formatTime(duration);
  851. },
  852. toggleLock() {
  853. window.socket.emit("stations.toggleLock", this.station._id, res => {
  854. if (res.status === "success") {
  855. new Toast({
  856. content: "Successfully toggled the queue lock.",
  857. timeout: 4000
  858. });
  859. } else new Toast({ content: res.message, timeout: 8000 });
  860. });
  861. },
  862. changeVolume() {
  863. const volume = this.volumeSliderValue;
  864. localStorage.setItem("volume", volume / 100);
  865. if (this.playerReady) {
  866. this.player.setVolume(volume / 100);
  867. if (volume > 0) {
  868. this.player.unMute();
  869. localStorage.setItem("muted", false);
  870. this.muted = false;
  871. }
  872. }
  873. },
  874. resumeLocalStation() {
  875. this.updateLocalPaused(false);
  876. if (!this.stationPaused) this.resumeLocalPlayer();
  877. },
  878. pauseLocalStation() {
  879. this.updateLocalPaused(true);
  880. this.pauseLocalPlayer();
  881. },
  882. resumeLocalPlayer() {
  883. if (!this.noSong) {
  884. if (this.playerReady) {
  885. this.player.seekTo(
  886. this.getTimeElapsed() / 1000 +
  887. this.currentSong.skipDuration
  888. );
  889. this.player.playVideo();
  890. }
  891. }
  892. },
  893. pauseLocalPlayer() {
  894. if (!this.noSong) {
  895. this.timeBeforePause = this.getTimeElapsed();
  896. if (this.playerReady) this.player.pauseVideo();
  897. }
  898. },
  899. skipStation() {
  900. this.socket.emit("stations.forceSkip", this.station._id, data => {
  901. if (data.status !== "success")
  902. new Toast({
  903. content: `Error: ${data.message}`,
  904. timeout: 8000
  905. });
  906. else
  907. new Toast({
  908. content:
  909. "Successfully skipped the station's current song.",
  910. timeout: 4000
  911. });
  912. });
  913. },
  914. voteSkipStation() {
  915. this.socket.emit("stations.voteSkip", this.station._id, data => {
  916. if (data.status !== "success")
  917. new Toast({
  918. content: `Error: ${data.message}`,
  919. timeout: 8000
  920. });
  921. else
  922. new Toast({
  923. content: "Successfully voted to skip the current song.",
  924. timeout: 4000
  925. });
  926. });
  927. },
  928. resumeStation() {
  929. this.socket.emit("stations.resume", this.station._id, data => {
  930. if (data.status !== "success")
  931. new Toast({
  932. content: `Error: ${data.message}`,
  933. timeout: 8000
  934. });
  935. else
  936. new Toast({
  937. content: "Successfully resumed the station.",
  938. timeout: 4000
  939. });
  940. });
  941. },
  942. pauseStation() {
  943. this.socket.emit("stations.pause", this.station._id, data => {
  944. if (data.status !== "success")
  945. new Toast({
  946. content: `Error: ${data.message}`,
  947. timeout: 8000
  948. });
  949. else
  950. new Toast({
  951. content: "Successfully paused the station.",
  952. timeout: 4000
  953. });
  954. });
  955. },
  956. toggleMute() {
  957. if (this.playerReady) {
  958. const previousVolume = parseFloat(
  959. localStorage.getItem("volume")
  960. );
  961. const volume =
  962. this.player.getVolume() * 100 <= 0 ? previousVolume : 0;
  963. this.muted = !this.muted;
  964. localStorage.setItem("muted", this.muted);
  965. this.volumeSliderValue = volume * 100;
  966. this.player.setVolume(volume);
  967. if (!this.muted) localStorage.setItem("volume", volume);
  968. }
  969. },
  970. increaseVolume() {
  971. if (this.playerReady) {
  972. const previousVolume = parseInt(localStorage.getItem("volume"));
  973. let volume = previousVolume + 5;
  974. if (previousVolume === 0) {
  975. this.muted = false;
  976. localStorage.setItem("muted", false);
  977. }
  978. if (volume > 100) volume = 100;
  979. this.volumeSliderValue = volume * 100;
  980. this.player.setVolume(volume);
  981. localStorage.setItem("volume", volume);
  982. }
  983. },
  984. toggleLike() {
  985. if (this.liked)
  986. this.socket.emit(
  987. "songs.unlike",
  988. this.currentSong.songId,
  989. data => {
  990. if (data.status !== "success")
  991. new Toast({
  992. content: `Error: ${data.message}`,
  993. timeout: 8000
  994. });
  995. }
  996. );
  997. else
  998. this.socket.emit(
  999. "songs.like",
  1000. this.currentSong.songId,
  1001. data => {
  1002. if (data.status !== "success")
  1003. new Toast({
  1004. content: `Error: ${data.message}`,
  1005. timeout: 8000
  1006. });
  1007. }
  1008. );
  1009. },
  1010. toggleDislike() {
  1011. if (this.disliked)
  1012. return this.socket.emit(
  1013. "songs.undislike",
  1014. this.currentSong.songId,
  1015. data => {
  1016. if (data.status !== "success")
  1017. new Toast({
  1018. content: `Error: ${data.message}`,
  1019. timeout: 8000
  1020. });
  1021. }
  1022. );
  1023. return this.socket.emit(
  1024. "songs.dislike",
  1025. this.currentSong.songId,
  1026. data => {
  1027. if (data.status !== "success")
  1028. new Toast({
  1029. content: `Error: ${data.message}`,
  1030. timeout: 8000
  1031. });
  1032. }
  1033. );
  1034. },
  1035. addFirstPrivatePlaylistSongToQueue() {
  1036. let isInQueue = false;
  1037. if (
  1038. this.station.type === "community" &&
  1039. this.station.partyMode === true
  1040. ) {
  1041. this.songsList.forEach(queueSong => {
  1042. if (queueSong.requestedBy === this.userId) isInQueue = true;
  1043. });
  1044. if (!isInQueue && this.privatePlaylistQueueSelected) {
  1045. this.socket.emit(
  1046. "playlists.getFirstSong",
  1047. this.privatePlaylistQueueSelected,
  1048. data => {
  1049. if (data.status === "success") {
  1050. if (data.song) {
  1051. if (data.song.duration < 15 * 60) {
  1052. this.automaticallyRequestedSongId =
  1053. data.song.songId;
  1054. this.socket.emit(
  1055. "stations.addToQueue",
  1056. this.station._id,
  1057. data.song.songId,
  1058. data2 => {
  1059. if (
  1060. data2.status === "success"
  1061. ) {
  1062. this.socket.emit(
  1063. "playlists.moveSongToBottom",
  1064. this
  1065. .privatePlaylistQueueSelected,
  1066. data.song.songId,
  1067. data3 => {
  1068. if (
  1069. data3.status ===
  1070. "success"
  1071. ) {
  1072. console.log(
  1073. "This comment is just here because of eslint/prettier issues, ignore it"
  1074. );
  1075. }
  1076. }
  1077. );
  1078. }
  1079. }
  1080. );
  1081. } else {
  1082. new Toast({
  1083. content: `Top song in playlist was too long to be added.`,
  1084. timeout: 3000
  1085. });
  1086. this.socket.emit(
  1087. "playlists.moveSongToBottom",
  1088. this.privatePlaylistQueueSelected,
  1089. data.song.songId,
  1090. data3 => {
  1091. if (
  1092. data3.status === "success"
  1093. ) {
  1094. setTimeout(() => {
  1095. this.addFirstPrivatePlaylistSongToQueue();
  1096. }, 3000);
  1097. }
  1098. }
  1099. );
  1100. }
  1101. } else {
  1102. new Toast({
  1103. content: `Selected playlist has no songs.`,
  1104. timeout: 4000
  1105. });
  1106. }
  1107. }
  1108. }
  1109. );
  1110. }
  1111. }
  1112. },
  1113. togglePlayerDebugBox() {
  1114. this.$refs.playerDebugBox.toggleBox();
  1115. },
  1116. resetPlayerDebugBox() {
  1117. this.$refs.playerDebugBox.resetBox();
  1118. },
  1119. join() {
  1120. this.socket.emit("stations.join", this.stationName, res => {
  1121. if (res.status === "success") {
  1122. this.loading = false;
  1123. const {
  1124. _id,
  1125. displayName,
  1126. description,
  1127. privacy,
  1128. locked,
  1129. partyMode,
  1130. owner,
  1131. privatePlaylist,
  1132. type
  1133. } = res.data;
  1134. this.joinStation({
  1135. _id,
  1136. name: this.stationName,
  1137. displayName,
  1138. description,
  1139. privacy,
  1140. locked,
  1141. partyMode,
  1142. owner,
  1143. privatePlaylist,
  1144. type
  1145. });
  1146. const currentSong = res.data.currentSong
  1147. ? res.data.currentSong
  1148. : {};
  1149. if (currentSong.artists)
  1150. currentSong.artists = currentSong.artists.join(", ");
  1151. if (currentSong && !currentSong.thumbnail)
  1152. currentSong.ytThumbnail = `https://img.youtube.com/vi/${currentSong.songId}/mqdefault.jpg`;
  1153. this.updateCurrentSong(currentSong);
  1154. this.startedAt = res.data.startedAt;
  1155. this.updateStationPaused(res.data.paused);
  1156. this.timePaused = res.data.timePaused;
  1157. this.updateUserCount(res.data.userCount);
  1158. this.updateUsers(res.data.users);
  1159. this.pausedAt = res.data.pausedAt;
  1160. if (res.data.currentSong) {
  1161. this.updateNoSong(false);
  1162. this.youtubeReady();
  1163. this.playVideo();
  1164. this.socket.emit(
  1165. "songs.getOwnSongRatings",
  1166. res.data.currentSong.songId,
  1167. data => {
  1168. if (this.currentSong.songId === data.songId) {
  1169. this.liked = data.liked;
  1170. this.disliked = data.disliked;
  1171. }
  1172. }
  1173. );
  1174. } else {
  1175. if (this.playerReady) this.player.pauseVideo();
  1176. this.updateNoSong(true);
  1177. }
  1178. if (type === "community" && partyMode === true) {
  1179. this.socket.emit("stations.getQueue", _id, res => {
  1180. if (res.status === "success") {
  1181. this.updateSongsList(res.queue);
  1182. }
  1183. });
  1184. }
  1185. if (this.isOwnerOrAdmin()) {
  1186. keyboardShortcuts.registerShortcut(
  1187. "station.pauseResume",
  1188. {
  1189. keyCode: 32,
  1190. shift: false,
  1191. ctrl: true,
  1192. preventDefault: true,
  1193. handler: () => {
  1194. if (this.stationPaused)
  1195. this.resumeStation();
  1196. else this.pauseStation();
  1197. }
  1198. }
  1199. );
  1200. keyboardShortcuts.registerShortcut(
  1201. "station.skipStation",
  1202. {
  1203. keyCode: 39,
  1204. shift: false,
  1205. ctrl: true,
  1206. preventDefault: true,
  1207. handler: () => {
  1208. this.skipStation();
  1209. }
  1210. }
  1211. );
  1212. }
  1213. keyboardShortcuts.registerShortcut(
  1214. "station.lowerVolumeLarge",
  1215. {
  1216. keyCode: 40,
  1217. shift: false,
  1218. ctrl: true,
  1219. preventDefault: true,
  1220. handler: () => {
  1221. this.volumeSliderValue -= 1000;
  1222. this.changeVolume();
  1223. }
  1224. }
  1225. );
  1226. keyboardShortcuts.registerShortcut(
  1227. "station.lowerVolumeSmall",
  1228. {
  1229. keyCode: 40,
  1230. shift: true,
  1231. ctrl: true,
  1232. preventDefault: true,
  1233. handler: () => {
  1234. this.volumeSliderValue -= 100;
  1235. this.changeVolume();
  1236. }
  1237. }
  1238. );
  1239. keyboardShortcuts.registerShortcut(
  1240. "station.increaseVolumeLarge",
  1241. {
  1242. keyCode: 38,
  1243. shift: false,
  1244. ctrl: true,
  1245. preventDefault: true,
  1246. handler: () => {
  1247. this.volumeSliderValue += 1000;
  1248. this.changeVolume();
  1249. }
  1250. }
  1251. );
  1252. keyboardShortcuts.registerShortcut(
  1253. "station.increaseVolumeSmall",
  1254. {
  1255. keyCode: 38,
  1256. shift: true,
  1257. ctrl: true,
  1258. preventDefault: true,
  1259. handler: () => {
  1260. this.volumeSliderValue += 100;
  1261. this.changeVolume();
  1262. }
  1263. }
  1264. );
  1265. keyboardShortcuts.registerShortcut("station.toggleDebug", {
  1266. keyCode: 68,
  1267. shift: false,
  1268. ctrl: true,
  1269. preventDefault: true,
  1270. handler: () => {
  1271. this.togglePlayerDebugBox();
  1272. }
  1273. });
  1274. // UNIX client time before ping
  1275. const beforePing = Date.now();
  1276. this.socket.emit("apis.ping", pong => {
  1277. // UNIX client time after ping
  1278. const afterPing = Date.now();
  1279. // Average time in MS it took between the server responding and the client receiving
  1280. const connectionLatency = (afterPing - beforePing) / 2;
  1281. console.log(connectionLatency, beforePing - afterPing);
  1282. // UNIX server time
  1283. const serverDate = pong.date;
  1284. // Difference between the server UNIX time and the client UNIX time after ping, with the connectionLatency added to the server UNIX time
  1285. const difference =
  1286. serverDate + connectionLatency - afterPing;
  1287. console.log("Difference: ", difference);
  1288. if (difference > 3000 || difference < -3000) {
  1289. console.log(
  1290. "System time difference is bigger than 3 seconds."
  1291. );
  1292. }
  1293. this.systemDifference = difference;
  1294. });
  1295. } else {
  1296. this.loading = false;
  1297. this.exists = false;
  1298. }
  1299. });
  1300. this.socket.emit("users.getFavoriteStations", data => {
  1301. if (
  1302. data.status === "success" &&
  1303. data.favoriteStations.indexOf(this.station._id) !== -1
  1304. )
  1305. this.favoriteStation = true;
  1306. });
  1307. },
  1308. addfavoriteStation(event) {
  1309. event.preventDefault();
  1310. this.socket.emit(
  1311. "stations.favoriteStation",
  1312. this.station._id,
  1313. res => {
  1314. if (res.status === "success") {
  1315. new Toast({
  1316. content: "Successfully favorited station.",
  1317. timeout: 4000
  1318. });
  1319. } else new Toast({ content: res.message, timeout: 8000 });
  1320. }
  1321. );
  1322. },
  1323. unfavoriteStation(event) {
  1324. event.preventDefault();
  1325. this.socket.emit(
  1326. "stations.unfavoriteStation",
  1327. this.station._id,
  1328. res => {
  1329. if (res.status === "success") {
  1330. new Toast({
  1331. content: "Successfully unfavorited station.",
  1332. timeout: 4000
  1333. });
  1334. } else new Toast({ content: res.message, timeout: 8000 });
  1335. }
  1336. );
  1337. },
  1338. ...mapActions("modals", ["openModal"]),
  1339. ...mapActions("station", [
  1340. "joinStation",
  1341. "updateUserCount",
  1342. "updateUsers",
  1343. "updateCurrentSong",
  1344. "updatePreviousSong",
  1345. "updateSongsList",
  1346. "updateStationPaused",
  1347. "updateLocalPaused",
  1348. "updateNoSong",
  1349. "editStation"
  1350. ])
  1351. }
  1352. };
  1353. </script>
  1354. <style lang="scss" scoped>
  1355. @import "../../styles/global.scss";
  1356. .main-container {
  1357. min-height: calc(100vh + 180px);
  1358. }
  1359. .progress {
  1360. width: 50px;
  1361. animation: rotate 0.8s infinite linear;
  1362. border: 8px solid $primary-color;
  1363. border-right-color: transparent;
  1364. height: 50px;
  1365. position: absolute;
  1366. top: 50%;
  1367. left: 50%;
  1368. }
  1369. @keyframes rotate {
  1370. 0% {
  1371. transform: rotate(0deg);
  1372. }
  1373. 100% {
  1374. transform: rotate(360deg);
  1375. }
  1376. }
  1377. .experimental {
  1378. display: none !important;
  1379. }
  1380. #player-debug-box {
  1381. .box-body {
  1382. flex-direction: column;
  1383. b {
  1384. color: #000;
  1385. }
  1386. }
  1387. }
  1388. .night-mode {
  1389. #currently-playing-container,
  1390. #about-station-container,
  1391. #control-bar-container,
  1392. .player-container.nothing-here {
  1393. background-color: $night-mode-bg-secondary !important;
  1394. }
  1395. #upper-row .quadrant,
  1396. #video-container,
  1397. #control-bar-container {
  1398. border: 0 !important;
  1399. }
  1400. #dropdown-toggle {
  1401. background-color: $dark-grey !important;
  1402. border: 0;
  1403. i {
  1404. color: #fff;
  1405. }
  1406. }
  1407. }
  1408. #station-outer-container {
  1409. margin: 0 auto;
  1410. max-width: 100%;
  1411. padding: 20px 40px;
  1412. margin-top: 5px;
  1413. height: 100%;
  1414. /** Mobile Row */
  1415. @media (max-width: 1040px) {
  1416. padding: 0;
  1417. margin-top: 0 !important;
  1418. height: auto !important;
  1419. #station-inner-container {
  1420. justify-content: flex-start !important;
  1421. }
  1422. .row {
  1423. width: 100%;
  1424. flex-direction: column !important;
  1425. }
  1426. .quadrant,
  1427. .player-container {
  1428. width: 100% !important;
  1429. border: 0 !important;
  1430. }
  1431. .quadrant,
  1432. .player-container {
  1433. background: transparent !important;
  1434. }
  1435. /** padding fixes on mobile */
  1436. #about-station-container,
  1437. #currently-playing-container {
  1438. padding: 15px 10px !important;
  1439. }
  1440. #about-station-container:not(.nothing-here) {
  1441. padding-bottom: 0 !important;
  1442. }
  1443. #currently-playing {
  1444. padding: 0;
  1445. }
  1446. /** no column gap between quadrants on mobile */
  1447. #currently-playing-container,
  1448. #sidebar-container {
  1449. margin-left: 0 !important;
  1450. }
  1451. #lower-row {
  1452. margin-top: 0 !important;
  1453. }
  1454. /** Change height of YouTube embed */
  1455. .player-container:not(.nothing-here) {
  1456. height: 800px !important;
  1457. }
  1458. .player-container {
  1459. height: 50px;
  1460. }
  1461. /** mainly irrelevant on mobile */
  1462. .no-currently-playing {
  1463. display: none !important;
  1464. }
  1465. }
  1466. #station-inner-container {
  1467. display: flex;
  1468. align-items: center;
  1469. flex-direction: column;
  1470. height: 100%;
  1471. @media (min-height: 1050px) {
  1472. justify-content: center;
  1473. }
  1474. @media (min-width: 1040px) and (max-width: 2100px) {
  1475. #control-bar-container {
  1476. .optional-desktop-only-text {
  1477. display: none;
  1478. }
  1479. .button:not(#dropdown-toggle) {
  1480. width: 75px;
  1481. }
  1482. #add-song-to-playlist .button,
  1483. #local-resume,
  1484. #local-pause {
  1485. i {
  1486. margin-right: 0 !important;
  1487. }
  1488. }
  1489. }
  1490. }
  1491. .row {
  1492. display: flex;
  1493. flex-direction: row;
  1494. max-width: 100%;
  1495. .quadrant {
  1496. display: flex;
  1497. align-items: center;
  1498. justify-content: center;
  1499. flex-direction: column;
  1500. max-width: 100%;
  1501. border-radius: 5px;
  1502. }
  1503. }
  1504. #upper-row {
  1505. .quadrant {
  1506. border: 1px solid $light-grey-2;
  1507. background-color: #fff;
  1508. }
  1509. #about-station-container {
  1510. width: 1400px;
  1511. align-items: flex-start;
  1512. padding: 20px;
  1513. #station-name {
  1514. flex-direction: row !important;
  1515. h1 {
  1516. margin: 0;
  1517. font-size: 36px;
  1518. }
  1519. i {
  1520. margin-left: 10px;
  1521. font-size: 30px;
  1522. color: $yellow;
  1523. }
  1524. }
  1525. p {
  1526. max-width: 700px;
  1527. flex-grow: 1;
  1528. }
  1529. #admin-buttons {
  1530. margin-top: 15px;
  1531. @media (max-width: 450px) {
  1532. .optional-desktop-only-text {
  1533. display: none;
  1534. }
  1535. }
  1536. }
  1537. }
  1538. #currently-playing-container {
  1539. width: 550px;
  1540. margin-left: 50px;
  1541. }
  1542. }
  1543. #lower-row {
  1544. margin-top: 20px;
  1545. height: calc(100% - 75px); // accounts for footer
  1546. .player-container.nothing-here {
  1547. border: 1px solid $light-grey-2;
  1548. border-radius: 5px;
  1549. }
  1550. .player-container {
  1551. height: inherit;
  1552. width: 1400px;
  1553. background-color: #fff;
  1554. display: flex;
  1555. flex-direction: column;
  1556. border: 1px solid $light-grey-2;
  1557. border-radius: 5px;
  1558. overflow: hidden;
  1559. #video-container {
  1560. width: 100%;
  1561. height: 100%;
  1562. .player-cannot-autoplay {
  1563. position: relative;
  1564. width: 100%;
  1565. height: 100%;
  1566. bottom: calc(100% + 5px);
  1567. background: rgba(3, 169, 244, 0.95);
  1568. display: flex;
  1569. align-items: center;
  1570. justify-content: center;
  1571. p {
  1572. color: $white;
  1573. font-size: 26px;
  1574. text-align: center;
  1575. }
  1576. }
  1577. }
  1578. #seeker-bar-container {
  1579. background-color: #fff;
  1580. position: relative;
  1581. height: 7px;
  1582. display: block;
  1583. width: 100%;
  1584. overflow: hidden;
  1585. #seeker-bar {
  1586. background-color: $musare-blue;
  1587. top: 0;
  1588. left: 0;
  1589. bottom: 0;
  1590. position: absolute;
  1591. }
  1592. }
  1593. #control-bar-container {
  1594. display: flex;
  1595. justify-content: space-around;
  1596. padding: 10px 0;
  1597. width: 100%;
  1598. background: #fff;
  1599. flex-direction: column;
  1600. flex-flow: wrap;
  1601. #left-buttons,
  1602. #right-buttons {
  1603. margin: 3px;
  1604. i {
  1605. margin-right: 3px;
  1606. }
  1607. }
  1608. #left-buttons {
  1609. display: flex;
  1610. .button:not(:first-of-type) {
  1611. margin-left: 5px;
  1612. }
  1613. }
  1614. #duration {
  1615. margin: 3px;
  1616. display: flex;
  1617. align-items: center;
  1618. p {
  1619. font-size: 22px;
  1620. /** prevents duration width slightly varying and shifting other controls slightly */
  1621. width: 125px;
  1622. text-align: center;
  1623. }
  1624. }
  1625. #volume-control {
  1626. margin: 3px;
  1627. margin-top: 0;
  1628. position: relative;
  1629. display: flex;
  1630. align-items: center;
  1631. cursor: pointer;
  1632. .volume-slider {
  1633. width: 500px;
  1634. padding: 0 15px;
  1635. background: transparent;
  1636. @media (max-width: 2150px) {
  1637. width: 250px !important;
  1638. }
  1639. }
  1640. input[type="range"] {
  1641. -webkit-appearance: none;
  1642. margin: 7.3px 0;
  1643. }
  1644. input[type="range"]:focus {
  1645. outline: none;
  1646. }
  1647. input[type="range"]::-webkit-slider-runnable-track {
  1648. width: 100%;
  1649. height: 5.2px;
  1650. cursor: pointer;
  1651. box-shadow: 0;
  1652. background: $light-grey-2;
  1653. border-radius: 0;
  1654. border: 0;
  1655. }
  1656. input[type="range"]::-webkit-slider-thumb {
  1657. box-shadow: 0;
  1658. border: 0;
  1659. height: 19px;
  1660. width: 19px;
  1661. border-radius: 15px;
  1662. background: $primary-color;
  1663. cursor: pointer;
  1664. -webkit-appearance: none;
  1665. margin-top: -6.5px;
  1666. }
  1667. input[type="range"]::-moz-range-track {
  1668. width: 100%;
  1669. height: 5.2px;
  1670. cursor: pointer;
  1671. box-shadow: 0;
  1672. background: $light-grey-2;
  1673. border-radius: 0;
  1674. border: 0;
  1675. }
  1676. input[type="range"]::-moz-range-thumb {
  1677. box-shadow: 0;
  1678. border: 0;
  1679. height: 19px;
  1680. width: 19px;
  1681. border-radius: 15px;
  1682. background: $primary-color;
  1683. cursor: pointer;
  1684. -webkit-appearance: none;
  1685. margin-top: -6.5px;
  1686. }
  1687. input[type="range"]::-ms-track {
  1688. width: 100%;
  1689. height: 5.2px;
  1690. cursor: pointer;
  1691. box-shadow: 0;
  1692. background: $light-grey-2;
  1693. border-radius: 1.3px;
  1694. }
  1695. input[type="range"]::-ms-fill-lower {
  1696. background: $light-grey-2;
  1697. border: 0;
  1698. border-radius: 0;
  1699. box-shadow: 0;
  1700. }
  1701. input[type="range"]::-ms-fill-upper {
  1702. background: $light-grey-2;
  1703. border: 0;
  1704. border-radius: 0;
  1705. box-shadow: 0;
  1706. }
  1707. input[type="range"]::-ms-thumb {
  1708. box-shadow: 0;
  1709. border: 0;
  1710. height: 15px;
  1711. width: 15px;
  1712. border-radius: 15px;
  1713. background: $primary-color;
  1714. cursor: pointer;
  1715. -webkit-appearance: none;
  1716. margin-top: 1.5px;
  1717. }
  1718. }
  1719. #right-buttons {
  1720. display: flex;
  1721. #dropdown-toggle {
  1722. width: 35px;
  1723. }
  1724. #dislike-song,
  1725. #add-song-to-playlist .button:not(#dropdown-toggle) {
  1726. margin-left: 5px;
  1727. }
  1728. #ratings {
  1729. display: flex;
  1730. #like-song:hover,
  1731. #like-song.liked {
  1732. background-color: darken($green, 5%) !important;
  1733. }
  1734. #dislike-song:hover,
  1735. #dislike-song.disliked {
  1736. background-color: darken($red, 5%) !important;
  1737. }
  1738. &.liked #dislike-song,
  1739. &.disliked #like-song {
  1740. background-color: $grey !important;
  1741. &:hover {
  1742. background-color: darken(
  1743. $grey,
  1744. 5%
  1745. ) !important;
  1746. }
  1747. }
  1748. }
  1749. #add-song-to-playlist {
  1750. display: flex;
  1751. flex-direction: column-reverse;
  1752. align-items: center;
  1753. width: 212px;
  1754. .control {
  1755. width: fit-content;
  1756. margin-bottom: 0 !important;
  1757. }
  1758. }
  1759. }
  1760. }
  1761. }
  1762. #sidebar-container {
  1763. position: relative;
  1764. width: 550px;
  1765. height: inherit;
  1766. margin-left: 50px;
  1767. }
  1768. }
  1769. }
  1770. }
  1771. /deep/ .nothing-here {
  1772. display: flex;
  1773. align-items: center;
  1774. justify-content: center;
  1775. text-transform: uppercase;
  1776. }
  1777. </style>