Station.vue 27 KB

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