Station.vue 27 KB

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