Station.vue 45 KB

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