Station.vue 29 KB

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