Station.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023
  1. <template>
  2. <official-header v-if='type == "official"'></official-header>
  3. <community-header v-if='type == "community"'></community-header>
  4. <song-queue v-if='modals.addSongToQueue'></song-queue>
  5. <add-to-playlist v-if='modals.addSongToPlaylist'></add-to-playlist>
  6. <edit-playlist v-if='modals.editPlaylist'></edit-playlist>
  7. <create-playlist v-if='modals.createPlaylist'></create-playlist>
  8. <edit-station v-show='modals.editStation'></edit-station>
  9. <report v-if='modals.report'></report>
  10. <songs-list-sidebar v-if='sidebars.songslist'></songs-list-sidebar>
  11. <playlist-sidebar v-if='sidebars.playlist'></playlist-sidebar>
  12. <users-sidebar v-if='sidebars.users'></users-sidebar>
  13. <div class='progress' v-show='!ready'></div>
  14. <div class='station' v-show="ready">
  15. <div v-show="noSong" class="no-song">
  16. <h1>No song is currently playing</h1>
  17. <h4 v-if='type === "community" && station.partyMode'>
  18. <a href='#' class='no-song' @click='modals.addSongToQueue = true'>Add a song to the queue</a>
  19. </h4>
  20. <h4 v-if='type === "community" && !station.partyMode && $parent.userId === station.owner && !station.privatePlaylist'>
  21. <a href='#' class='no-song' @click='sidebars.playlist = true'>Play a private playlist</a>
  22. </h4>
  23. <h1 v-if='type === "community" && !station.partyMode && $parent.userId === station.owner && station.privatePlaylist'>Maybe you can add some songs to your selected private playlist and then press the skip button</h1>
  24. </div>
  25. <div class="columns" v-show="!noSong">
  26. <div class="column is-8-desktop is-offset-2-desktop is-12-mobile">
  27. <div class="video-container">
  28. <div id="player"></div>
  29. </div>
  30. <div class="seeker-bar-container white" id="preview-progress">
  31. <div class="seeker-bar light-blue" style="width: 0%;"></div>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="desktop-only columns is-mobile" v-show="!noSong">
  36. <div class="column is-8-desktop is-offset-2-desktop is-12-mobile">
  37. <div class="columns is-mobile">
  38. <div class="column is-12-desktop">
  39. <h4 id="time-display">{{timeElapsed}} / {{formatTime(currentSong.duration)}}</h4>
  40. <h3>{{currentSong.title}}</h3>
  41. <h4 class="thin" style="margin-left: 0">{{currentSong.artists}}</h4>
  42. <div class="columns is-mobile">
  43. <form style="margin-top: 12px; margin-bottom: 0;" action="#" class="column is-7-desktop is-4-mobile">
  44. <p class='volume-slider-wrapper'>
  45. <i class="material-icons" @click='toggleMute()' v-if='muted'>volume_mute</i>
  46. <i class="material-icons" @click='toggleMute()' v-else>volume_down</i>
  47. <input type="range" id="volumeSlider" min="0" max="100" class="active" v-on:change="changeVolume()" v-on:input="changeVolume()">
  48. <i class="material-icons" @click='increaseVolume()'>volume_up</i>
  49. </p>
  50. </form>
  51. <div class="column is-8-mobile is-5-desktop" style="float: right;">
  52. <ul id="ratings" v-if="currentSong.likes !== -1 && currentSong.dislikes !== -1">
  53. <li id="like" class="right" @click="toggleLike()">
  54. <span class="flow-text">{{currentSong.likes}} </span>
  55. <i id="thumbs_up" class="material-icons grey-text" v-bind:class="{ liked: liked }">thumb_up</i>
  56. <a class='absolute-a behind' @click="toggleLike()" href='#'></a>
  57. </li>
  58. <li style="margin-right: 10px;" id="dislike" class="right" @click="toggleDislike()">
  59. <span class="flow-text">{{currentSong.dislikes}} </span>
  60. <i id="thumbs_down" class="material-icons grey-text" v-bind:class="{ disliked: disliked }">thumb_down</i>
  61. <a class='absolute-a behind' @click="toggleDislike()" href='#'></a>
  62. </li>
  63. </ul>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. <div class="mobile-only" v-show="!noSong">
  71. <div>
  72. <div>
  73. <div>
  74. <h3>{{currentSong.title}}</h3>
  75. <h4 class="thin">{{currentSong.artists}}</h4>
  76. <h5>{{timeElapsed}} / {{formatTime(currentSong.duration)}}</h5>
  77. <div>
  78. <form class="columns" action="#">
  79. <p class='column is-11-mobile volume-slider-wrapper'>
  80. <i class="material-icons" @click='toggleMute()' v-if='muted'>volume_mute</i>
  81. <i class="material-icons" @click='toggleMute()' v-else>volume_down</i>
  82. <input type="range" id="volumeSlider" min="0" max="100" class="active" v-on:change="changeVolume()" v-on:input="changeVolume()">
  83. <i class="material-icons" @click='increaseVolume()'>volume_up</i>
  84. </p>
  85. </form>
  86. <div>
  87. <ul id="ratings" style="display: inline-block;" v-if="currentSong.likes !== -1 && currentSong.dislikes !== -1">
  88. <li id="dislike" style="display: inline-block;margin-right: 10px;" @click="toggleDislike()">
  89. <span class="flow-text">{{currentSong.dislikes}} </span>
  90. <i id="thumbs_down" class="material-icons grey-text" v-bind:class="{ disliked: disliked }">thumb_down</i>
  91. <a class='absolute-a behind' @click="toggleDislike()" href='#'></a>
  92. </li>
  93. <li id="like" style="display: inline-block;" @click="toggleLike()">
  94. <span class="flow-text">{{currentSong.likes}} </span>
  95. <i id="thumbs_up" class="material-icons grey-text" v-bind:class="{ liked: liked }">thumb_up</i>
  96. <a class='absolute-a behind' @click="toggleLike()" href='#'></a>
  97. </li>
  98. </ul>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. </template>
  107. <script>
  108. import { Toast } from 'vue-roaster';
  109. import SongQueue from '../Modals/AddSongToQueue.vue';
  110. import AddToPlaylist from '../Modals/AddSongToPlaylist.vue';
  111. import EditPlaylist from '../Modals/Playlists/Edit.vue';
  112. import CreatePlaylist from '../Modals/Playlists/Create.vue';
  113. import EditStation from '../Modals/EditStation.vue';
  114. import Report from '../Modals/Report.vue';
  115. import SongsListSidebar from '../Sidebars/SongsList.vue';
  116. import PlaylistSidebar from '../Sidebars/Playlist.vue';
  117. import UsersSidebar from '../Sidebars/UsersList.vue';
  118. import OfficialHeader from './OfficialHeader.vue';
  119. import CommunityHeader from './CommunityHeader.vue';
  120. import MainFooter from '../MainFooter.vue';
  121. import io from '../../io';
  122. import auth from '../../auth';
  123. export default {
  124. data() {
  125. return {
  126. ready: false,
  127. type: '',
  128. playerReady: false,
  129. previousSong: null,
  130. currentSong: {},
  131. player: undefined,
  132. timePaused: 0,
  133. paused: false,
  134. muted: false,
  135. timeElapsed: '0:00',
  136. liked: false,
  137. disliked: false,
  138. modals: {
  139. addSongToQueue: false,
  140. addSongToPlaylist: false,
  141. editPlaylist: false,
  142. createPlaylist: false,
  143. editStation: false,
  144. report: false
  145. },
  146. sidebars: {
  147. songslist: false,
  148. users: false,
  149. playlist: false
  150. },
  151. noSong: false,
  152. simpleSong: false,
  153. songsList: [],
  154. timeBeforePause: 0,
  155. station: {},
  156. skipVotes: 0,
  157. privatePlaylistQueueSelected: null,
  158. automaticallyRequestedSongId: null,
  159. systemDifference: 0,
  160. users: [],
  161. userCount: 0
  162. }
  163. },
  164. methods: {
  165. editPlaylist: function (id) {
  166. this.playlistBeingEdited = id;
  167. this.modals.editPlaylist = !this.modals.editPlaylist;
  168. },
  169. editStation: function () {
  170. let _this = this;
  171. this.$broadcast('editStation', {
  172. _id: _this.station._id,
  173. name: _this.station.name,
  174. type: _this.type,
  175. partyMode: _this.station.partyMode,
  176. description: _this.station.description,
  177. privacy: _this.station.privacy,
  178. displayName: _this.station.displayName
  179. });
  180. },
  181. toggleSidebar: function (type) {
  182. Object.keys(this.sidebars).forEach(sidebar => {
  183. if (sidebar !== type) this.sidebars[sidebar] = false;
  184. else this.sidebars[type] = !this.sidebars[type];
  185. });
  186. },
  187. youtubeReady: function() {
  188. let local = this;
  189. if (!local.player) {
  190. local.player = new YT.Player("player", {
  191. height: 270,
  192. width: 480,
  193. videoId: local.currentSong.songId,
  194. startSeconds: local.getTimeElapsed() / 1000 + local.currentSong.skipDuration,
  195. playerVars: {controls: 0, iv_load_policy: 3, rel: 0, showinfo: 0},
  196. events: {
  197. 'onReady': function (event) {
  198. local.playerReady = true;
  199. let volume = parseInt(localStorage.getItem("volume"));
  200. volume = (typeof volume === "number") ? volume : 20;
  201. local.player.setVolume(volume);
  202. if (volume > 0) local.player.unMute();
  203. local.playVideo();
  204. },
  205. 'onError': function(err) {
  206. console.log("iframe error", err);
  207. local.voteSkipStation();
  208. },
  209. 'onStateChange': function (event) {
  210. if (event.data === 1 && local.videoLoading === true) {
  211. local.videoLoading = false;
  212. local.player.seekTo(local.getTimeElapsed() / 1000 + local.currentSong.skipDuration, true);
  213. if (local.paused) local.player.pauseVideo();
  214. } else if (event.data === 1 && local.paused) {
  215. local.player.seekTo(local.timeBeforePause / 1000, true);
  216. local.player.pauseVideo();
  217. }
  218. if (event.data === 2 && !local.paused && !local.noSong && (local.player.getDuration() / 1000) < local.currentSong.duration) {
  219. local.player.seekTo(local.getTimeElapsed() / 1000 + local.currentSong.skipDuration, true);
  220. local.player.playVideo();
  221. }
  222. }
  223. }
  224. });
  225. }
  226. },
  227. getTimeElapsed: function() {
  228. let local = this;
  229. if (local.currentSong) return Date.currently() - local.startedAt - local.timePaused;
  230. else return 0;
  231. },
  232. playVideo: function() {
  233. let local = this;
  234. if (local.playerReady) {
  235. local.videoLoading = true;
  236. local.player.loadVideoById(local.currentSong.songId, local.getTimeElapsed() / 1000 + local.currentSong.skipDuration);
  237. if (local.currentSong.artists) local.currentSong.artists = local.currentSong.artists.join(", ");
  238. if (window.stationInterval !== 0) clearInterval(window.stationInterval);
  239. window.stationInterval = setInterval(function () {
  240. local.resizeSeekerbar();
  241. local.calculateTimeElapsed();
  242. }, 250);
  243. }
  244. },
  245. resizeSeekerbar: function() {
  246. let local = this;
  247. if (!local.paused) {
  248. $(".seeker-bar").width(parseInt(((local.getTimeElapsed() / 1000) / local.currentSong.duration * 100)) + "%");
  249. }
  250. },
  251. formatTime: function(duration) {
  252. let d = moment.duration(duration, 'seconds');
  253. if (duration < 0) return "0:00";
  254. return ((d.hours() > 0) ? (d.hours() < 10 ? ("0" + d.hours() + ":") : (d.hours() + ":")) : "") + (d.minutes() + ":") + (d.seconds() < 10 ? ("0" + d.seconds()) : d.seconds());
  255. },
  256. calculateTimeElapsed: function() {
  257. let local = this;
  258. let currentTime = Date.currently();
  259. if (local.currentTime !== undefined && local.paused) {
  260. local.timePaused += (Date.currently() - local.currentTime);
  261. local.currentTime = undefined;
  262. }
  263. let duration = (Date.currently() - local.startedAt - local.timePaused) / 1000;
  264. let songDuration = local.currentSong.duration;
  265. if (songDuration <= duration) local.player.pauseVideo();
  266. if ((!local.paused) && duration <= songDuration) local.timeElapsed = local.formatTime(duration);
  267. },
  268. changeVolume: function() {
  269. let local = this;
  270. let volume = $("#volumeSlider").val();
  271. localStorage.setItem("volume", volume);
  272. if (local.playerReady) {
  273. local.player.setVolume(volume);
  274. if (volume > 0) local.player.unMute();
  275. }
  276. },
  277. resumeLocalStation: function() {
  278. this.paused = false;
  279. if (!this.noSong) {
  280. if (this.playerReady) {
  281. this.player.seekTo(this.getTimeElapsed() / 1000 + this.currentSong.skipDuration);
  282. this.player.playVideo();
  283. }
  284. }
  285. },
  286. pauseLocalStation: function() {
  287. this.paused = true;
  288. if (!this.noSong) {
  289. this.timeBeforePause = this.getTimeElapsed();
  290. if (this.playerReady) this.player.pauseVideo();
  291. }
  292. },
  293. skipStation: function () {
  294. let _this = this;
  295. _this.socket.emit('stations.forceSkip', _this.station._id, data => {
  296. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  297. else Toast.methods.addToast('Successfully skipped the station\'s current song.', 4000);
  298. });
  299. },
  300. voteSkipStation: function () {
  301. let _this = this;
  302. _this.socket.emit('stations.voteSkip', _this.station._id, data => {
  303. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  304. else Toast.methods.addToast('Successfully voted to skip the current song.', 4000);
  305. });
  306. },
  307. resumeStation: function () {
  308. let _this = this;
  309. _this.socket.emit('stations.resume', _this.station._id, data => {
  310. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  311. else Toast.methods.addToast('Successfully resumed the station.', 4000);
  312. });
  313. },
  314. pauseStation: function () {
  315. let _this = this;
  316. _this.socket.emit('stations.pause', _this.station._id, data => {
  317. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  318. else Toast.methods.addToast('Successfully paused the station.', 4000);
  319. });
  320. },
  321. toggleMute: function () {
  322. if (this.playerReady) {
  323. let previousVolume = parseInt(localStorage.getItem("volume"));
  324. let volume = this.player.getVolume() <= 0 ? previousVolume : 0;
  325. this.muted = !this.muted;
  326. $("#volumeSlider").val(volume);
  327. this.player.setVolume(volume);
  328. if (!this.muted) localStorage.setItem("volume", volume);
  329. }
  330. },
  331. increaseVolume: function () {
  332. if (this.playerReady) {
  333. let previousVolume = parseInt(localStorage.getItem("volume"));
  334. let volume = previousVolume + 5;
  335. if (previousVolume === 0) this.muted = false;
  336. if (volume > 100) volume = 100;
  337. $("#volumeSlider").val(volume);
  338. this.player.setVolume(volume);
  339. localStorage.setItem("volume", volume);
  340. }
  341. },
  342. toggleLike: function() {
  343. let _this = this;
  344. if (_this.liked) _this.socket.emit('songs.unlike', _this.currentSong.songId, data => {
  345. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  346. }); else _this.socket.emit('songs.like', _this.currentSong.songId, data => {
  347. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  348. });
  349. },
  350. toggleDislike: function() {
  351. let _this = this;
  352. if (_this.disliked) return _this.socket.emit('songs.undislike', _this.currentSong.songId, data => {
  353. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  354. });
  355. _this.socket.emit('songs.dislike', _this.currentSong.songId, data => {
  356. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  357. });
  358. },
  359. addFirstPrivatePlaylistSongToQueue: function() {
  360. let _this = this;
  361. let isInQueue = false;
  362. let userId = _this.$parent.userId;
  363. if (_this.type === 'community') {
  364. _this.songsList.forEach((queueSong) => {
  365. if (queueSong.requestedBy === userId) isInQueue = true;
  366. });
  367. if (!isInQueue && _this.privatePlaylistQueueSelected) {
  368. _this.socket.emit('playlists.getFirstSong', _this.privatePlaylistQueueSelected, data => {
  369. if (data.status === 'success') {
  370. let songId = data.song._id;
  371. _this.automaticallyRequestedSongId = data.song.songId;
  372. _this.socket.emit('stations.addToQueue', _this.station._id, data.song.songId, data2 => {
  373. if (data2.status === 'success') {
  374. _this.socket.emit('playlists.moveSongToBottom', _this.privatePlaylistQueueSelected, data.song.songId, data3 => {
  375. if (data3.status === 'success') {}
  376. });
  377. }
  378. });
  379. }
  380. });
  381. }
  382. }
  383. },
  384. joinStation: function () {
  385. let _this = this;
  386. _this.socket.emit('stations.join', _this.stationName, res => {
  387. if (res.status === 'success') {
  388. _this.station = {
  389. _id: res.data._id,
  390. name: _this.stationName,
  391. displayName: res.data.displayName,
  392. description: res.data.description,
  393. privacy: res.data.privacy,
  394. partyMode: res.data.partyMode,
  395. owner: res.data.owner,
  396. privatePlaylist: res.data.privatePlaylist
  397. };
  398. _this.currentSong = (res.data.currentSong) ? res.data.currentSong : {};
  399. _this.type = res.data.type;
  400. _this.startedAt = res.data.startedAt;
  401. _this.paused = res.data.paused;
  402. _this.timePaused = res.data.timePaused;
  403. _this.userCount = res.data.userCount;
  404. _this.users = res.data.users;
  405. if (res.data.currentSong) {
  406. _this.noSong = false;
  407. _this.simpleSong = (res.data.currentSong.likes === -1 && res.data.currentSong.dislikes === -1);
  408. if (_this.simpleSong) {
  409. _this.currentSong.skipDuration = 0;
  410. }
  411. _this.youtubeReady();
  412. _this.playVideo();
  413. _this.socket.emit('songs.getOwnSongRatings', res.data.currentSong.songId, data => {
  414. if (_this.currentSong.songId === data.songId) {
  415. _this.liked = data.liked;
  416. _this.disliked = data.disliked;
  417. }
  418. });
  419. } else {
  420. if (_this.playerReady) _this.player.pauseVideo();
  421. _this.noSong = true;
  422. }
  423. if (_this.type === 'community') {
  424. _this.socket.emit('stations.getQueue', _this.station._id, data => {
  425. if (data.status === 'success') _this.songsList = data.queue;
  426. });
  427. }
  428. if (_this.type === 'official') {
  429. _this.socket.emit('stations.getPlaylist', _this.station._id, res => {
  430. if (res.status == 'success') _this.songsList = res.data;
  431. });
  432. }
  433. } else {
  434. _this.$router.go('/404');
  435. Toast.methods.addToast(res.message, 3000);
  436. }
  437. // UNIX client time before ping
  438. let beforePing = Date.now();
  439. _this.socket.emit('apis.ping', res => {
  440. // UNIX client time after ping
  441. let afterPing = Date.now();
  442. // Average time in MS it took between the server responding and the client receiving
  443. let connectionLatency = (afterPing - beforePing) / 2;
  444. console.log(connectionLatency, beforePing - afterPing);
  445. // UNIX server time
  446. let serverDate = res.date;
  447. // Difference between the server UNIX time and the client UNIX time after ping, with the connectionLatency added to the server UNIX time
  448. let difference = (serverDate + connectionLatency) - afterPing;
  449. console.log("Difference: ", difference);
  450. if (difference > 3000 || difference < -3000) {
  451. console.log("System time difference is bigger than 3 seconds.");
  452. }
  453. _this.systemDifference = difference;
  454. });
  455. });
  456. }
  457. },
  458. ready: function() {
  459. let _this = this;
  460. Date.currently = () => {
  461. return new Date().getTime() + _this.systemDifference;
  462. };
  463. _this.stationName = _this.$route.params.id;
  464. window.stationInterval = 0;
  465. io.getSocket(socket => {
  466. _this.socket = socket;
  467. io.removeAllListeners();
  468. if (_this.socket.connected) _this.joinStation();
  469. io.onConnect(() => {
  470. _this.joinStation();
  471. });
  472. _this.socket.emit('stations.findByName', _this.stationName, res => {
  473. if (res.status === 'error') {
  474. _this.$router.go('/404');
  475. Toast.methods.addToast(res.message, 3000);
  476. } else {
  477. _this.ready = true;
  478. }
  479. });
  480. _this.socket.on('event:songs.next', data => {
  481. _this.previousSong = (_this.currentSong.songId) ? _this.currentSong : null;
  482. _this.currentSong = (data.currentSong) ? data.currentSong : {};
  483. _this.startedAt = data.startedAt;
  484. _this.paused = data.paused;
  485. _this.timePaused = data.timePaused;
  486. if (data.currentSong) {
  487. _this.noSong = false;
  488. _this.simpleSong = (data.currentSong.likes === -1 && data.currentSong.dislikes === -1);
  489. if (_this.simpleSong) _this.currentSong.skipDuration = 0;
  490. if (!_this.playerReady) _this.youtubeReady();
  491. else _this.playVideo();
  492. _this.socket.emit('songs.getOwnSongRatings', data.currentSong.songId, (data) => {
  493. if (_this.currentSong.songId === data.songId) {
  494. _this.liked = data.liked;
  495. _this.disliked = data.disliked;
  496. }
  497. });
  498. } else {
  499. if (_this.playerReady) _this.player.pauseVideo();
  500. _this.noSong = true;
  501. }
  502. let isInQueue = false;
  503. let userId = _this.$parent.userId;
  504. _this.songsList.forEach((queueSong) => {
  505. if (queueSong.requestedBy === userId) isInQueue = true;
  506. });
  507. if (!isInQueue && _this.privatePlaylistQueueSelected && (_this.automaticallyRequestedSongId !== _this.currentSong.songId || !_this.currentSong.songId)) {
  508. _this.addFirstPrivatePlaylistSongToQueue();
  509. }
  510. });
  511. _this.socket.on('event:stations.pause', data => {
  512. _this.pauseLocalStation();
  513. });
  514. _this.socket.on('event:stations.resume', data => {
  515. _this.timePaused = data.timePaused;
  516. _this.resumeLocalStation();
  517. });
  518. _this.socket.on('event:stations.remove', () => {
  519. location.href = '/';
  520. });
  521. _this.socket.on('event:song.like', data => {
  522. if (!this.noSong) {
  523. if (data.songId === _this.currentSong.songId) {
  524. _this.currentSong.dislikes = data.dislikes;
  525. _this.currentSong.likes = data.likes;
  526. }
  527. }
  528. });
  529. _this.socket.on('event:song.dislike', data => {
  530. if (!this.noSong) {
  531. if (data.songId === _this.currentSong.songId) {
  532. _this.currentSong.dislikes = data.dislikes;
  533. _this.currentSong.likes = data.likes;
  534. }
  535. }
  536. });
  537. _this.socket.on('event:song.unlike', data => {
  538. if (!this.noSong) {
  539. if (data.songId === _this.currentSong.songId) {
  540. _this.currentSong.dislikes = data.dislikes;
  541. _this.currentSong.likes = data.likes;
  542. }
  543. }
  544. });
  545. _this.socket.on('event:song.undislike', data => {
  546. if (!this.noSong) {
  547. if (data.songId === _this.currentSong.songId) {
  548. _this.currentSong.dislikes = data.dislikes;
  549. _this.currentSong.likes = data.likes;
  550. }
  551. }
  552. });
  553. _this.socket.on('event:song.newRatings', data => {
  554. if (!this.noSong) {
  555. if (data.songId === _this.currentSong.songId) {
  556. _this.liked = data.liked;
  557. _this.disliked = data.disliked;
  558. }
  559. }
  560. });
  561. _this.socket.on('event:queue.update', queue => {
  562. if (this.type === 'community') this.songsList = queue;
  563. });
  564. _this.socket.on('event:song.voteSkipSong', () => {
  565. if (this.currentSong) this.currentSong.skipVotes++;
  566. });
  567. _this.socket.on('event:privatePlaylist.selected', (playlistId) => {
  568. if (this.type === 'community') {
  569. this.station.privatePlaylist = playlistId;
  570. }
  571. });
  572. _this.socket.on('event:partyMode.updated', (partyMode) => {
  573. if (this.type === 'community') {
  574. this.station.partyMode = partyMode;
  575. }
  576. });
  577. _this.socket.on('event:newOfficialPlaylist', (playlist) => {
  578. if (this.type === 'official') {
  579. this.songsList = playlist;
  580. }
  581. });
  582. _this.socket.on('event:users.updated', users => {
  583. _this.users = users;
  584. });
  585. _this.socket.on('event:userCount.updated', userCount => {
  586. _this.userCount = userCount;
  587. });
  588. });
  589. let volume = parseInt(localStorage.getItem("volume"));
  590. volume = (typeof volume === "number" && !isNaN(volume)) ? volume : 20;
  591. localStorage.setItem("volume", volume);
  592. $("#volumeSlider").val(volume);
  593. },
  594. components: {
  595. OfficialHeader,
  596. CommunityHeader,
  597. SongQueue,
  598. AddToPlaylist,
  599. EditPlaylist,
  600. CreatePlaylist,
  601. EditStation,
  602. Report,
  603. SongsListSidebar,
  604. PlaylistSidebar,
  605. UsersSidebar,
  606. MainFooter
  607. }
  608. }
  609. </script>
  610. <style lang="scss">
  611. .no-song {
  612. color: #03A9F4;
  613. text-align: center;
  614. }
  615. #volumeSlider {
  616. padding: 0 15px;
  617. background: transparent;
  618. }
  619. .volume-slider-wrapper {
  620. margin-top: 0;
  621. position: relative;
  622. display: flex;
  623. align-items: center;
  624. .material-icons { user-select: none; }
  625. }
  626. .material-icons { cursor: pointer; }
  627. .stationDisplayName {
  628. color: white !important;
  629. }
  630. .add-to-playlist {
  631. display: flex;
  632. align-items: center;
  633. justify-content: center;
  634. }
  635. .slideout {
  636. top: 50px;
  637. height: 100%;
  638. position: fixed;
  639. right: 0;
  640. width: 350px;
  641. background-color: white;
  642. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  643. .slideout-header {
  644. text-align: center;
  645. background-color: rgb(3, 169, 244) !important;
  646. margin: 0;
  647. padding-top: 5px;
  648. padding-bottom: 7px;
  649. color: white;
  650. }
  651. .slideout-content {
  652. height: 100%;
  653. }
  654. }
  655. .modal-large {
  656. width: 75%;
  657. }
  658. .station {
  659. flex: 1 0 auto;
  660. padding-top: 0.5vw;
  661. transition: all 0.1s;
  662. margin: 0 auto;
  663. max-width: 100%;
  664. width: 90%;
  665. @media only screen and (min-width: 993px) {
  666. width: 70%;
  667. }
  668. @media only screen and (min-width: 601px) {
  669. width: 85%;
  670. }
  671. @media (min-width: 999px) {
  672. .mobile-only {
  673. display: none;
  674. }
  675. .desktop-only {
  676. display: block;
  677. }
  678. }
  679. @media (max-width: 998px) {
  680. .mobile-only {
  681. display: block;
  682. }
  683. .desktop-only {
  684. display: none;
  685. visibility: hidden;
  686. }
  687. }
  688. .mobile-only {
  689. text-align: center;
  690. }
  691. input[type=range] {
  692. -webkit-appearance: none;
  693. width: 100%;
  694. margin: 7.3px 0;
  695. }
  696. input[type=range]:focus {
  697. outline: none;
  698. }
  699. input[type=range]::-webkit-slider-runnable-track {
  700. width: 100%;
  701. height: 5.2px;
  702. cursor: pointer;
  703. box-shadow: 0;
  704. background: #c2c0c2;
  705. border-radius: 0;
  706. border: 0;
  707. }
  708. input[type=range]::-webkit-slider-thumb {
  709. box-shadow: 0;
  710. border: 0;
  711. height: 19px;
  712. width: 19px;
  713. border-radius: 15px;
  714. background: #03a9f4;
  715. cursor: pointer;
  716. -webkit-appearance: none;
  717. margin-top: -6.5px;
  718. }
  719. input[type=range]::-moz-range-track {
  720. width: 100%;
  721. height: 5.2px;
  722. cursor: pointer;
  723. box-shadow: 0;
  724. background: #c2c0c2;
  725. border-radius: 0;
  726. border: 0;
  727. }
  728. input[type=range]::-moz-range-thumb {
  729. box-shadow: 0;
  730. border: 0;
  731. height: 19px;
  732. width: 19px;
  733. border-radius: 15px;
  734. background: #03a9f4;
  735. cursor: pointer;
  736. -webkit-appearance: none;
  737. margin-top: -6.5px;
  738. }
  739. input[type=range]::-ms-track {
  740. width: 100%;
  741. height: 5.2px;
  742. cursor: pointer;
  743. box-shadow: 0;
  744. background: #c2c0c2;
  745. border-radius: 1.3px;
  746. }
  747. input[type=range]::-ms-fill-lower {
  748. background: #c2c0c2;
  749. border: 0;
  750. border-radius: 0;
  751. box-shadow: 0;
  752. }
  753. input[type=range]::-ms-fill-upper {
  754. background: #c2c0c2;
  755. border: 0;
  756. border-radius: 0;
  757. box-shadow: 0;
  758. }
  759. input[type=range]::-ms-thumb {
  760. box-shadow: 0;
  761. border: 0;
  762. height: 15px;
  763. width: 15px;
  764. border-radius: 15px;
  765. background: #03a9f4;
  766. cursor: pointer;
  767. -webkit-appearance: none;
  768. margin-top: 1.5px;
  769. }
  770. .video-container {
  771. position: relative;
  772. padding-bottom: 56.25%;
  773. height: 0;
  774. overflow: hidden;
  775. iframe {
  776. position: absolute;
  777. top: 0;
  778. left: 0;
  779. width: 100%;
  780. height: 100%;
  781. }
  782. }
  783. .video-col {
  784. padding-right: 0.75rem;
  785. padding-left: 0.75rem;
  786. }
  787. }
  788. .room-title {
  789. left: 50%;
  790. -webkit-transform: translateX(-50%);
  791. transform: translateX(-50%);
  792. font-size: 2.1em;
  793. }
  794. #ratings {
  795. span {
  796. font-size: 1.68rem;
  797. }
  798. i {
  799. color: #9e9e9e !important;
  800. cursor: pointer;
  801. transition: 0.1s color;
  802. }
  803. }
  804. #time-display {
  805. margin-top: 30px;
  806. float: right;
  807. }
  808. #thumbs_up:hover, #thumbs_up.liked {
  809. color: #87D37C !important;
  810. }
  811. #thumbs_down:hover, #thumbs_down.disliked {
  812. color: #EC644B !important;
  813. }
  814. #song-thumbnail {
  815. max-width: 100%;
  816. width: 85%;
  817. }
  818. .seeker-bar-container {
  819. position: relative;
  820. height: 7px;
  821. display: block;
  822. width: 100%;
  823. overflow: hidden;
  824. }
  825. .seeker-bar {
  826. top: 0;
  827. left: 0;
  828. bottom: 0;
  829. position: absolute;
  830. }
  831. ul {
  832. list-style: none;
  833. margin: 0;
  834. display: block;
  835. }
  836. h1, h2, h3, h4, h5, h6 {
  837. font-weight: 400;
  838. line-height: 1.1;
  839. }
  840. h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
  841. font-weight: inherit;
  842. }
  843. h1 {
  844. font-size: 4.2rem;
  845. line-height: 110%;
  846. margin: 2.1rem 0 1.68rem 0;
  847. }
  848. h2 {
  849. font-size: 3.56rem;
  850. line-height: 110%;
  851. margin: 1.78rem 0 1.424rem 0;
  852. }
  853. h3 {
  854. font-size: 2.92rem;
  855. line-height: 110%;
  856. margin: 1.46rem 0 1.168rem 0;
  857. }
  858. h4 {
  859. font-size: 2.28rem;
  860. line-height: 110%;
  861. margin: 1.14rem 0 0.912rem 0;
  862. }
  863. h5 {
  864. font-size: 1.64rem;
  865. line-height: 110%;
  866. margin: 0.82rem 0 0.656rem 0;
  867. }
  868. h6 {
  869. font-size: 1rem;
  870. line-height: 110%;
  871. margin: 0.5rem 0 0.4rem 0;
  872. }
  873. .thin {
  874. font-weight: 200;
  875. }
  876. .left {
  877. float: left !important;
  878. }
  879. .right {
  880. float: right !important;
  881. }
  882. .light-blue {
  883. background-color: #03a9f4 !important;
  884. }
  885. .white {
  886. background-color: #FFFFFF !important;
  887. }
  888. .btn-search {
  889. font-size: 14px;
  890. }
  891. .menu { padding: 0 10px; }
  892. .menu-list li a:hover { color: #000 !important; }
  893. .menu-list li {
  894. display: flex;
  895. justify-content: space-between;
  896. }
  897. .menu-list a {
  898. /*padding: 0 10px !important;*/
  899. }
  900. .menu-list a:hover {
  901. background-color : transparent;
  902. }
  903. .icons-group { display: flex; }
  904. #like, #dislike {
  905. position: relative;
  906. }
  907. .behind {
  908. z-index: -1;
  909. }
  910. .behind:focus {
  911. z-index: 0;
  912. }
  913. .progress {
  914. width: 50px;
  915. animation: rotate 0.8s infinite linear;
  916. border: 8px solid #03A9F4;
  917. border-right-color: transparent;
  918. height: 50px;
  919. position: absolute;
  920. top: 50%;
  921. left: 50%;
  922. }
  923. @keyframes rotate {
  924. 0% { transform: rotate(0deg); }
  925. 100% { transform: rotate(360deg); }
  926. }
  927. </style>