Station.vue 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  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. 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) {
  334. this.muted = false;
  335. }
  336. if (volume > 100) {
  337. volume = 100;
  338. }
  339. console.log(previousVolume, volume);
  340. $("#volumeSlider").val(volume);
  341. this.player.setVolume(volume);
  342. localStorage.setItem("volume", volume);
  343. }
  344. },
  345. toggleLike: function() {
  346. let _this = this;
  347. if (_this.liked) _this.socket.emit('songs.unlike', _this.currentSong.songId, data => {
  348. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  349. }); else _this.socket.emit('songs.like', _this.currentSong.songId, data => {
  350. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  351. });
  352. },
  353. toggleDislike: function() {
  354. let _this = this;
  355. if (_this.disliked) return _this.socket.emit('songs.undislike', _this.currentSong.songId, data => {
  356. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  357. });
  358. _this.socket.emit('songs.dislike', _this.currentSong.songId, data => {
  359. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  360. });
  361. },
  362. addFirstPrivatePlaylistSongToQueue: function() {
  363. let _this = this;
  364. let isInQueue = false;
  365. let userId = _this.$parent.userId;
  366. if (_this.type === 'community') {
  367. _this.songsList.forEach((queueSong) => {
  368. if (queueSong.requestedBy === userId) isInQueue = true;
  369. });
  370. if (!isInQueue && _this.privatePlaylistQueueSelected) {
  371. _this.socket.emit('playlists.getFirstSong', _this.privatePlaylistQueueSelected, data => {
  372. if (data.status === 'success') {
  373. console.log(data.song);
  374. let songId = data.song._id;
  375. _this.automaticallyRequestedSongId = data.song.songId;
  376. _this.socket.emit('stations.addToQueue', _this.station._id, data.song.songId, data => {
  377. if (data.status === 'success') {
  378. _this.socket.emit('playlists.moveSongToBottom', _this.privatePlaylistQueueSelected, songId, data => {
  379. if (data.status === 'success') {}
  380. });
  381. }
  382. });
  383. }
  384. });
  385. }
  386. }
  387. },
  388. joinStation: function () {
  389. let _this = this;
  390. _this.socket.emit('stations.join', _this.stationName, res => {
  391. if (res.status === 'success') {
  392. _this.station = {
  393. _id: res.data._id,
  394. name: _this.stationName,
  395. displayName: res.data.displayName,
  396. description: res.data.description,
  397. privacy: res.data.privacy,
  398. partyMode: res.data.partyMode,
  399. owner: res.data.owner,
  400. privatePlaylist: res.data.privatePlaylist
  401. };
  402. _this.currentSong = (res.data.currentSong) ? res.data.currentSong : {};
  403. _this.type = res.data.type;
  404. _this.startedAt = res.data.startedAt;
  405. _this.paused = res.data.paused;
  406. _this.timePaused = res.data.timePaused;
  407. _this.userCount = res.data.userCount;
  408. _this.users = res.data.users;
  409. if (res.data.currentSong) {
  410. _this.noSong = false;
  411. _this.simpleSong = (res.data.currentSong.likes === -1 && res.data.currentSong.dislikes === -1);
  412. if (_this.simpleSong) {
  413. _this.currentSong.skipDuration = 0;
  414. }
  415. _this.youtubeReady();
  416. _this.playVideo();
  417. _this.socket.emit('songs.getOwnSongRatings', res.data.currentSong._id, data => {
  418. if (_this.currentSong.songId === data.songId) {
  419. _this.liked = data.liked;
  420. _this.disliked = data.disliked;
  421. }
  422. });
  423. } else {
  424. if (_this.playerReady) _this.player.pauseVideo();
  425. _this.noSong = true;
  426. }
  427. if (_this.type === 'community') {
  428. _this.socket.emit('stations.getQueue', _this.station._id, data => {
  429. if (data.status === 'success') _this.songsList = data.queue;
  430. });
  431. }
  432. if (_this.type === 'official') {
  433. _this.socket.emit('stations.getPlaylist', _this.station._id, res => {
  434. if (res.status == 'success') _this.songsList = res.data;
  435. });
  436. }
  437. } else {
  438. _this.$router.go('/404');
  439. Toast.methods.addToast(res.message, 3000);
  440. }
  441. // UNIX client time before ping
  442. let beforePing = Date.now();
  443. _this.socket.emit('apis.ping', res => {
  444. // UNIX client time after ping
  445. let afterPing = Date.now();
  446. // Average time in MS it took between the server responding and the client receiving
  447. let connectionLatency = (afterPing - beforePing) / 2;
  448. console.log(connectionLatency, beforePing - afterPing);
  449. // UNIX server time
  450. let serverDate = res.date;
  451. // Difference between the server UNIX time and the client UNIX time after ping, with the connectionLatency added to the server UNIX time
  452. let difference = (serverDate + connectionLatency) - afterPing;
  453. console.log("Difference: ", difference);
  454. if (difference > 3000 || difference < -3000) {
  455. console.log("System time difference is bigger than 3 seconds.");
  456. }
  457. _this.systemDifference = difference;
  458. });
  459. });
  460. }
  461. },
  462. ready: function() {
  463. let _this = this;
  464. Date.currently = () => {
  465. return new Date().getTime() + _this.systemDifference;
  466. };
  467. _this.stationName = _this.$route.params.id;
  468. window.stationInterval = 0;
  469. io.getSocket(socket => {
  470. _this.socket = socket;
  471. io.removeAllListeners();
  472. if (_this.socket.connected) _this.joinStation();
  473. io.onConnect(() => {
  474. _this.joinStation();
  475. });
  476. _this.socket.emit('stations.findByName', _this.stationName, res => {
  477. if (res.status === 'error') {
  478. _this.$router.go('/404');
  479. Toast.methods.addToast(res.message, 3000);
  480. }
  481. });
  482. _this.socket.on('event:songs.next', data => {
  483. _this.previousSong = (_this.currentSong.songId) ? _this.currentSong : null;
  484. _this.currentSong = (data.currentSong) ? data.currentSong : {};
  485. _this.startedAt = data.startedAt;
  486. _this.paused = data.paused;
  487. _this.timePaused = data.timePaused;
  488. if (data.currentSong) {
  489. _this.noSong = false;
  490. _this.simpleSong = (data.currentSong.likes === -1 && data.currentSong.dislikes === -1);
  491. if (_this.simpleSong) _this.currentSong.skipDuration = 0;
  492. if (!_this.playerReady) _this.youtubeReady();
  493. else _this.playVideo();
  494. _this.socket.emit('songs.getOwnSongRatings', data.currentSong.songId, (data) => {
  495. if (_this.currentSong.songId === data.songId) {
  496. _this.liked = data.liked;
  497. _this.disliked = data.disliked;
  498. }
  499. });
  500. } else {
  501. if (_this.playerReady) _this.player.pauseVideo();
  502. _this.noSong = true;
  503. }
  504. let isInQueue = false;
  505. let userId = _this.$parent.userId;
  506. _this.songsList.forEach((queueSong) => {
  507. if (queueSong.requestedBy === userId) isInQueue = true;
  508. });
  509. if (!isInQueue && _this.privatePlaylistQueueSelected && (_this.automaticallyRequestedSongId !== _this.currentSong.songId || !_this.currentSong.songId)) {
  510. _this.addFirstPrivatePlaylistSongToQueue();
  511. }
  512. });
  513. _this.socket.on('event:stations.pause', data => {
  514. _this.pauseLocalStation();
  515. });
  516. _this.socket.on('event:stations.resume', data => {
  517. _this.timePaused = data.timePaused;
  518. _this.resumeLocalStation();
  519. });
  520. _this.socket.on('event:stations.remove', () => {
  521. location.href = '/';
  522. });
  523. _this.socket.on('event:song.like', data => {
  524. if (!this.noSong) {
  525. if (data.songId === _this.currentSong.songId) {
  526. _this.currentSong.dislikes = data.dislikes;
  527. _this.currentSong.likes = data.likes;
  528. }
  529. }
  530. });
  531. _this.socket.on('event:song.dislike', data => {
  532. if (!this.noSong) {
  533. if (data.songId === _this.currentSong.songId) {
  534. _this.currentSong.dislikes = data.dislikes;
  535. _this.currentSong.likes = data.likes;
  536. }
  537. }
  538. });
  539. _this.socket.on('event:song.unlike', data => {
  540. if (!this.noSong) {
  541. if (data.songId === _this.currentSong.songId) {
  542. _this.currentSong.dislikes = data.dislikes;
  543. _this.currentSong.likes = data.likes;
  544. }
  545. }
  546. });
  547. _this.socket.on('event:song.undislike', data => {
  548. if (!this.noSong) {
  549. if (data.songId === _this.currentSong.songId) {
  550. _this.currentSong.dislikes = data.dislikes;
  551. _this.currentSong.likes = data.likes;
  552. }
  553. }
  554. });
  555. _this.socket.on('event:song.newRatings', data => {
  556. if (!this.noSong) {
  557. if (data.songId === _this.currentSong.songId) {
  558. _this.liked = data.liked;
  559. _this.disliked = data.disliked;
  560. }
  561. }
  562. });
  563. _this.socket.on('event:queue.update', queue => {
  564. if (this.type === 'community') this.songsList = queue;
  565. });
  566. _this.socket.on('event:song.voteSkipSong', () => {
  567. if (this.currentSong) this.currentSong.skipVotes++;
  568. });
  569. _this.socket.on('event:privatePlaylist.selected', (playlistId) => {
  570. if (this.type === 'community') {
  571. this.station.privatePlaylist = playlistId;
  572. }
  573. });
  574. _this.socket.on('event:partyMode.updated', (partyMode) => {
  575. if (this.type === 'community') {
  576. this.station.partyMode = partyMode;
  577. }
  578. });
  579. _this.socket.on('event:newOfficialPlaylist', (playlist) => {
  580. console.log(playlist);
  581. if (this.type === 'official') {
  582. this.songsList = playlist;
  583. }
  584. });
  585. _this.socket.on('event:users.updated', users => {
  586. _this.users = users;
  587. });
  588. _this.socket.on('event:userCount.updated', userCount => {
  589. _this.userCount = userCount;
  590. });
  591. });
  592. let volume = parseInt(localStorage.getItem("volume"));
  593. volume = (typeof volume === "number" && !isNaN(volume)) ? volume : 20;
  594. localStorage.setItem("volume", volume);
  595. $("#volumeSlider").val(volume);
  596. },
  597. components: {
  598. OfficialHeader,
  599. CommunityHeader,
  600. SongQueue,
  601. AddToPlaylist,
  602. EditPlaylist,
  603. CreatePlaylist,
  604. EditStation,
  605. Report,
  606. SongsListSidebar,
  607. PlaylistSidebar,
  608. UsersSidebar,
  609. MainFooter
  610. }
  611. }
  612. </script>
  613. <style lang="scss">
  614. .no-song {
  615. color: #03A9F4;
  616. text-align: center;
  617. }
  618. #volumeSlider {
  619. padding: 0 15px;
  620. background: transparent;
  621. }
  622. .volume-slider-wrapper {
  623. margin-top: 0;
  624. position: relative;
  625. display: flex;
  626. align-items: center;
  627. }
  628. .material-icons { cursor: pointer; }
  629. .stationDisplayName {
  630. color: white !important;
  631. }
  632. .add-to-playlist {
  633. display: flex;
  634. align-items: center;
  635. justify-content: center;
  636. }
  637. .slideout {
  638. top: 50px;
  639. height: 100%;
  640. position: fixed;
  641. right: 0;
  642. width: 350px;
  643. background-color: white;
  644. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  645. .slideout-header {
  646. text-align: center;
  647. background-color: rgb(3, 169, 244) !important;
  648. margin: 0;
  649. padding-top: 5px;
  650. padding-bottom: 7px;
  651. color: white;
  652. }
  653. .slideout-content {
  654. height: 100%;
  655. }
  656. }
  657. .modal-large {
  658. width: 75%;
  659. }
  660. .station {
  661. flex: 1 0 auto;
  662. padding-top: 0.5vw;
  663. transition: all 0.1s;
  664. margin: 0 auto;
  665. max-width: 100%;
  666. width: 90%;
  667. @media only screen and (min-width: 993px) {
  668. width: 70%;
  669. }
  670. @media only screen and (min-width: 601px) {
  671. width: 85%;
  672. }
  673. @media (min-width: 999px) {
  674. .mobile-only {
  675. display: none;
  676. }
  677. .desktop-only {
  678. display: block;
  679. }
  680. }
  681. @media (max-width: 998px) {
  682. .mobile-only {
  683. display: block;
  684. }
  685. .desktop-only {
  686. display: none;
  687. visibility: hidden;
  688. }
  689. }
  690. .mobile-only {
  691. text-align: center;
  692. }
  693. input[type=range] {
  694. -webkit-appearance: none;
  695. width: 100%;
  696. margin: 7.3px 0;
  697. }
  698. input[type=range]:focus {
  699. outline: none;
  700. }
  701. input[type=range]::-webkit-slider-runnable-track {
  702. width: 100%;
  703. height: 5.2px;
  704. cursor: pointer;
  705. box-shadow: 0;
  706. background: #c2c0c2;
  707. border-radius: 0;
  708. border: 0;
  709. }
  710. input[type=range]::-webkit-slider-thumb {
  711. box-shadow: 0;
  712. border: 0;
  713. height: 19px;
  714. width: 19px;
  715. border-radius: 15px;
  716. background: #03a9f4;
  717. cursor: pointer;
  718. -webkit-appearance: none;
  719. margin-top: -6.5px;
  720. }
  721. input[type=range]::-moz-range-track {
  722. width: 100%;
  723. height: 5.2px;
  724. cursor: pointer;
  725. box-shadow: 0;
  726. background: #c2c0c2;
  727. border-radius: 0;
  728. border: 0;
  729. }
  730. input[type=range]::-moz-range-thumb {
  731. box-shadow: 0;
  732. border: 0;
  733. height: 19px;
  734. width: 19px;
  735. border-radius: 15px;
  736. background: #03a9f4;
  737. cursor: pointer;
  738. -webkit-appearance: none;
  739. margin-top: -6.5px;
  740. }
  741. input[type=range]::-ms-track {
  742. width: 100%;
  743. height: 5.2px;
  744. cursor: pointer;
  745. box-shadow: 0;
  746. background: #c2c0c2;
  747. border-radius: 1.3px;
  748. }
  749. input[type=range]::-ms-fill-lower {
  750. background: #c2c0c2;
  751. border: 0;
  752. border-radius: 0;
  753. box-shadow: 0;
  754. }
  755. input[type=range]::-ms-fill-upper {
  756. background: #c2c0c2;
  757. border: 0;
  758. border-radius: 0;
  759. box-shadow: 0;
  760. }
  761. input[type=range]::-ms-thumb {
  762. box-shadow: 0;
  763. border: 0;
  764. height: 15px;
  765. width: 15px;
  766. border-radius: 15px;
  767. background: #03a9f4;
  768. cursor: pointer;
  769. -webkit-appearance: none;
  770. margin-top: 1.5px;
  771. }
  772. .video-container {
  773. position: relative;
  774. padding-bottom: 56.25%;
  775. height: 0;
  776. overflow: hidden;
  777. iframe {
  778. position: absolute;
  779. top: 0;
  780. left: 0;
  781. width: 100%;
  782. height: 100%;
  783. }
  784. }
  785. .video-col {
  786. padding-right: 0.75rem;
  787. padding-left: 0.75rem;
  788. }
  789. }
  790. .room-title {
  791. left: 50%;
  792. -webkit-transform: translateX(-50%);
  793. transform: translateX(-50%);
  794. font-size: 2.1em;
  795. }
  796. #ratings {
  797. span {
  798. font-size: 1.68rem;
  799. }
  800. i {
  801. color: #9e9e9e !important;
  802. cursor: pointer;
  803. transition: 0.1s color;
  804. }
  805. }
  806. #time-display {
  807. margin-top: 30px;
  808. float: right;
  809. }
  810. #thumbs_up:hover, #thumbs_up.liked {
  811. color: #87D37C !important;
  812. }
  813. #thumbs_down:hover, #thumbs_down.disliked {
  814. color: #EC644B !important;
  815. }
  816. #song-thumbnail {
  817. max-width: 100%;
  818. width: 85%;
  819. }
  820. .seeker-bar-container {
  821. position: relative;
  822. height: 7px;
  823. display: block;
  824. width: 100%;
  825. overflow: hidden;
  826. }
  827. .seeker-bar {
  828. top: 0;
  829. left: 0;
  830. bottom: 0;
  831. position: absolute;
  832. }
  833. ul {
  834. list-style: none;
  835. margin: 0;
  836. display: block;
  837. }
  838. h1, h2, h3, h4, h5, h6 {
  839. font-weight: 400;
  840. line-height: 1.1;
  841. }
  842. h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
  843. font-weight: inherit;
  844. }
  845. h1 {
  846. font-size: 4.2rem;
  847. line-height: 110%;
  848. margin: 2.1rem 0 1.68rem 0;
  849. }
  850. h2 {
  851. font-size: 3.56rem;
  852. line-height: 110%;
  853. margin: 1.78rem 0 1.424rem 0;
  854. }
  855. h3 {
  856. font-size: 2.92rem;
  857. line-height: 110%;
  858. margin: 1.46rem 0 1.168rem 0;
  859. }
  860. h4 {
  861. font-size: 2.28rem;
  862. line-height: 110%;
  863. margin: 1.14rem 0 0.912rem 0;
  864. }
  865. h5 {
  866. font-size: 1.64rem;
  867. line-height: 110%;
  868. margin: 0.82rem 0 0.656rem 0;
  869. }
  870. h6 {
  871. font-size: 1rem;
  872. line-height: 110%;
  873. margin: 0.5rem 0 0.4rem 0;
  874. }
  875. .thin {
  876. font-weight: 200;
  877. }
  878. .left {
  879. float: left !important;
  880. }
  881. .right {
  882. float: right !important;
  883. }
  884. .light-blue {
  885. background-color: #03a9f4 !important;
  886. }
  887. .white {
  888. background-color: #FFFFFF !important;
  889. }
  890. .btn-search {
  891. font-size: 14px;
  892. }
  893. .menu { padding: 0 10px; }
  894. .menu-list li a:hover { color: #000 !important; }
  895. .menu-list li {
  896. display: flex;
  897. justify-content: space-between;
  898. }
  899. .menu-list a {
  900. /*padding: 0 10px !important;*/
  901. }
  902. .menu-list a:hover {
  903. background-color : transparent;
  904. }
  905. .icons-group { display: flex; }
  906. #like, #dislike {
  907. position: relative;
  908. }
  909. .behind {
  910. z-index: -1;
  911. }
  912. .behind:focus {
  913. z-index: 0;
  914. }
  915. </style>