Station.vue 28 KB

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