index.vue 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000
  1. <template>
  2. <div>
  3. <page-metadata
  4. v-if="exists && !loading"
  5. :title="`${station.displayName}`"
  6. />
  7. <page-metadata v-else-if="!exists && !loading" :title="`Not found`" />
  8. <div id="page-loader-container" v-if="loading">
  9. <content-loader
  10. width="1920"
  11. height="1080"
  12. :primary-color="nightmode ? '#222' : '#fff'"
  13. :secondary-color="nightmode ? '#444' : '#ddd'"
  14. preserve-aspect-ratio="none"
  15. id="page-loader-content"
  16. >
  17. <rect x="55" y="105" rx="5" ry="5" width="670" height="149" />
  18. <rect x="55" y="283" rx="5" ry="5" width="670" height="640" />
  19. <rect x="745" y="108" rx="5" ry="5" width="1120" height="672" />
  20. <rect x="745" y="810" rx="5" ry="5" width="1120" height="110" />
  21. </content-loader>
  22. <content-loader
  23. width="1920"
  24. height="1080"
  25. :primary-color="nightmode ? '#222' : '#fff'"
  26. :secondary-color="nightmode ? '#444' : '#ddd'"
  27. preserve-aspect-ratio="none"
  28. id="page-loader-layout"
  29. >
  30. <rect x="0" y="0" rx="0" ry="0" width="1920" height="64" />
  31. <rect x="0" y="980" rx="0" ry="0" width="1920" height="100" />
  32. </content-loader>
  33. </div>
  34. <!-- More simplistic loading animation for mobile users -->
  35. <div v-show="loading" id="mobile-progress-animation" />
  36. <ul
  37. v-if="
  38. currentSong &&
  39. (currentSong.youtubeId === 'l9PxOanFjxQ' ||
  40. currentSong.youtubeId === 'xKVcVSYmesU' ||
  41. currentSong.youtubeId === '60ItHLz5WEA')
  42. "
  43. class="bg-bubbles"
  44. >
  45. <li></li>
  46. <li></li>
  47. <li></li>
  48. <li></li>
  49. <li></li>
  50. <li></li>
  51. <li></li>
  52. <li></li>
  53. <li></li>
  54. <li></li>
  55. </ul>
  56. <div v-show="!loading && exists">
  57. <main-header />
  58. <div id="station-outer-container">
  59. <div
  60. id="station-inner-container"
  61. :class="{ 'nothing-here': noSong }"
  62. >
  63. <div id="station-left-column" class="column">
  64. <div id="about-station-container" class="quadrant">
  65. <div id="station-info">
  66. <div class="row" id="station-name">
  67. <h1>{{ station.displayName }}</h1>
  68. <a href="#">
  69. <!-- Favorite Station Button -->
  70. <i
  71. v-if="
  72. loggedIn && station.isFavorited
  73. "
  74. @click.prevent="unfavoriteStation()"
  75. content="Unfavorite Station"
  76. v-tippy
  77. class="material-icons"
  78. >star</i
  79. >
  80. <i
  81. v-if="
  82. loggedIn && !station.isFavorited
  83. "
  84. @click.prevent="favoriteStation()"
  85. class="material-icons"
  86. content="Favorite Station"
  87. v-tippy
  88. >star_border</i
  89. >
  90. </a>
  91. <i
  92. class="material-icons stationMode"
  93. :content="
  94. station.partyMode
  95. ? 'Station in Party mode'
  96. : 'Station in Playlist mode'
  97. "
  98. v-tippy="{ theme: 'info' }"
  99. >{{
  100. station.partyMode
  101. ? "emoji_people"
  102. : "playlist_play"
  103. }}</i
  104. >
  105. </div>
  106. <p>{{ station.description }}</p>
  107. </div>
  108. <div id="admin-buttons" v-if="isOwnerOrAdmin()">
  109. <!-- (Admin) Pause/Resume Button -->
  110. <button
  111. class="button is-danger"
  112. v-if="stationPaused"
  113. @click="resumeStation()"
  114. >
  115. <i class="material-icons icon-with-button"
  116. >play_arrow</i
  117. >
  118. <span> Resume Station </span>
  119. </button>
  120. <button
  121. class="button is-danger"
  122. @click="pauseStation()"
  123. v-else
  124. >
  125. <i class="material-icons icon-with-button"
  126. >pause</i
  127. >
  128. <span> Pause Station </span>
  129. </button>
  130. <!-- (Admin) Skip Button -->
  131. <button
  132. class="button is-danger"
  133. @click="skipStation()"
  134. >
  135. <i class="material-icons icon-with-button"
  136. >skip_next</i
  137. >
  138. <span> Force Skip </span>
  139. </button>
  140. <!-- (Admin) Station Settings Button -->
  141. <button
  142. class="button is-primary"
  143. @click="openModal('manageStation')"
  144. >
  145. <i class="material-icons icon-with-button"
  146. >settings</i
  147. >
  148. <span> Manage Station </span>
  149. </button>
  150. </div>
  151. </div>
  152. <div id="sidebar-container" class="quadrant">
  153. <station-sidebar />
  154. </div>
  155. </div>
  156. <div id="station-right-column" class="column">
  157. <div class="player-container quadrant" v-show="!noSong">
  158. <div id="video-container">
  159. <div
  160. id="stationPlayer"
  161. style="
  162. width: 100%;
  163. height: 100%;
  164. min-height: 200px;
  165. "
  166. />
  167. <div
  168. class="player-cannot-autoplay"
  169. v-if="!canAutoplay"
  170. @click="
  171. increaseVolume() && decreaseVolume()
  172. "
  173. >
  174. <p>
  175. Please click anywhere on the screen for
  176. the video to start
  177. </p>
  178. </div>
  179. </div>
  180. <div id="seeker-bar-container">
  181. <div
  182. id="seeker-bar"
  183. :style="{
  184. width: `${seekerbarPercentage}%`
  185. }"
  186. :class="{
  187. nyan:
  188. currentSong &&
  189. currentSong.youtubeId ===
  190. 'QH2-TGUlwu4'
  191. }"
  192. />
  193. <img
  194. v-if="
  195. currentSong &&
  196. currentSong.youtubeId === 'QH2-TGUlwu4'
  197. "
  198. src="https://freepngimg.com/thumb/nyan_cat/1-2-nyan-cat-free-download-png.png"
  199. :style="{
  200. position: 'absolute',
  201. top: `-10px`,
  202. left: `${seekerbarPercentage}%`,
  203. width: '50px'
  204. }"
  205. />
  206. <img
  207. v-if="
  208. currentSong &&
  209. (currentSong.youtubeId ===
  210. 'DtVBCG6ThDk' ||
  211. currentSong.youtubeId ===
  212. 'sI66hcu9fIs' ||
  213. currentSong.youtubeId ===
  214. 'iYYRH4apXDo' ||
  215. currentSong.youtubeId ===
  216. 'tRcPA7Fzebw')
  217. "
  218. src="/assets/rocket.svg"
  219. :style="{
  220. position: 'absolute',
  221. top: `-21px`,
  222. left: `calc(${seekerbarPercentage}% - 35px)`,
  223. width: '50px',
  224. transform: 'rotate(45deg)'
  225. }"
  226. />
  227. <img
  228. v-if="
  229. currentSong &&
  230. currentSong.youtubeId === 'jofNR_WkoCE'
  231. "
  232. src="/assets/fox.svg"
  233. :style="{
  234. position: 'absolute',
  235. top: `-21px`,
  236. left: `calc(${seekerbarPercentage}% - 35px)`,
  237. width: '50px',
  238. transform: 'scaleX(-1)',
  239. opacity: 1
  240. }"
  241. />
  242. <img
  243. v-if="
  244. currentSong &&
  245. (currentSong.youtubeId ===
  246. 'l9PxOanFjxQ' ||
  247. currentSong.youtubeId ===
  248. 'xKVcVSYmesU' ||
  249. currentSong.youtubeId ===
  250. '60ItHLz5WEA')
  251. "
  252. src="/assets/old_logo.png"
  253. :style="{
  254. position: 'absolute',
  255. top: `-9px`,
  256. left: `calc(${seekerbarPercentage}% - 22px)`,
  257. 'background-color': 'rgb(96, 199, 169)',
  258. width: '25px',
  259. height: '25px',
  260. 'border-radius': '25px'
  261. }"
  262. />
  263. </div>
  264. <div id="control-bar-container">
  265. <div id="left-buttons">
  266. <!-- Debug Box -->
  267. <button
  268. v-if="frontendDevMode === 'development'"
  269. class="button is-primary"
  270. @click="togglePlayerDebugBox()"
  271. @dblclick="resetPlayerDebugBox()"
  272. content="Debug"
  273. v-tippy
  274. >
  275. <i
  276. class="
  277. material-icons
  278. icon-with-button
  279. "
  280. >
  281. bug_report
  282. </i>
  283. </button>
  284. <!-- Local Pause/Resume Button -->
  285. <button
  286. class="button is-primary"
  287. @click="resumeLocalStation()"
  288. id="local-resume"
  289. v-if="localPaused"
  290. content="Unpause Playback"
  291. v-tippy
  292. >
  293. <i class="material-icons">play_arrow</i>
  294. </button>
  295. <button
  296. class="button is-primary"
  297. @click="pauseLocalStation()"
  298. id="local-pause"
  299. v-else
  300. content="Pause Playback"
  301. v-tippy
  302. >
  303. <i class="material-icons">pause</i>
  304. </button>
  305. <!-- Vote to Skip Button -->
  306. <button
  307. v-if="!skipVotesLoaded"
  308. class="button is-primary disabled"
  309. content="Skip votes have not been loaded yet"
  310. v-tippy
  311. >
  312. <i
  313. class="
  314. material-icons
  315. icon-with-button
  316. "
  317. >skip_next</i
  318. >
  319. </button>
  320. <button
  321. v-else-if="loggedIn"
  322. class="button is-primary"
  323. @click="voteSkipStation()"
  324. content="Vote to Skip Song"
  325. v-tippy
  326. >
  327. <i
  328. class="
  329. material-icons
  330. icon-with-button
  331. "
  332. >skip_next</i
  333. >
  334. {{ currentSong.skipVotes }}
  335. </button>
  336. <button
  337. v-else
  338. class="button is-primary disabled"
  339. content="Log in to vote to skip songs"
  340. v-tippy="{ theme: 'info' }"
  341. >
  342. <i
  343. class="
  344. material-icons
  345. icon-with-button
  346. "
  347. >skip_next</i
  348. >
  349. {{ currentSong.skipVotes }}
  350. </button>
  351. </div>
  352. <div id="duration">
  353. <p>
  354. {{ timeElapsed }} /
  355. {{
  356. utils.formatTime(
  357. currentSong.duration
  358. )
  359. }}
  360. </p>
  361. </div>
  362. <p id="volume-control" v-if="!isApple">
  363. <i
  364. v-if="muted"
  365. class="material-icons"
  366. @click="toggleMute()"
  367. content="Unmute"
  368. v-tippy
  369. >volume_mute</i
  370. >
  371. <i
  372. v-else
  373. class="material-icons"
  374. @click="toggleMute()"
  375. content="Mute"
  376. v-tippy
  377. >volume_down</i
  378. >
  379. <input
  380. v-model="volumeSliderValue"
  381. type="range"
  382. min="0"
  383. max="10000"
  384. class="volume-slider active"
  385. @change="changeVolume()"
  386. @input="changeVolume()"
  387. />
  388. <i
  389. class="material-icons"
  390. @click="increaseVolume()"
  391. content="Increase Volume"
  392. v-tippy
  393. >volume_up</i
  394. >
  395. </p>
  396. <div id="right-buttons" v-if="loggedIn">
  397. <!-- Ratings (Like/Dislike) Buttons -->
  398. <div
  399. id="ratings"
  400. v-if="ratingsLoaded && ownRatingsLoaded"
  401. :class="{
  402. liked: currentSong.liked,
  403. disliked: currentSong.disliked
  404. }"
  405. >
  406. <!-- Like Song Button -->
  407. <button
  408. class="button is-success like-song"
  409. id="like-song"
  410. @click="toggleLike()"
  411. content="Like Song"
  412. v-tippy
  413. >
  414. <i
  415. class="
  416. material-icons
  417. icon-with-button
  418. "
  419. :class="{
  420. liked: currentSong.liked
  421. }"
  422. >thumb_up_alt</i
  423. >{{ currentSong.likes }}
  424. </button>
  425. <!-- Dislike Song Button -->
  426. <button
  427. class="
  428. button
  429. is-danger
  430. dislike-song
  431. "
  432. id="dislike-song"
  433. @click="toggleDislike()"
  434. content="Dislike Song"
  435. v-tippy
  436. >
  437. <i
  438. class="
  439. material-icons
  440. icon-with-button
  441. "
  442. :class="{
  443. disliked:
  444. currentSong.disliked
  445. }"
  446. >thumb_down_alt</i
  447. >{{ currentSong.dislikes }}
  448. </button>
  449. </div>
  450. <div id="ratings" class="disabled" v-else>
  451. <!-- Like Song Button -->
  452. <button
  453. class="
  454. button
  455. is-success
  456. like-song
  457. disabled
  458. "
  459. id="like-song"
  460. content="Ratings have not been loaded yet"
  461. v-tippy
  462. >
  463. <i
  464. class="
  465. material-icons
  466. icon-with-button
  467. "
  468. >thumb_up_alt</i
  469. >
  470. </button>
  471. <!-- Dislike Song Button -->
  472. <button
  473. class="
  474. button
  475. is-danger
  476. dislike-song
  477. disabled
  478. "
  479. id="dislike-song"
  480. content="Ratings have not been loaded yet"
  481. v-tippy
  482. >
  483. <i
  484. class="
  485. material-icons
  486. icon-with-button
  487. "
  488. >thumb_down_alt</i
  489. >
  490. </button>
  491. </div>
  492. <!-- Add Song To Playlist Button & Dropdown -->
  493. <add-to-playlist-dropdown
  494. :song="currentSong"
  495. placement="top-end"
  496. >
  497. <template #button>
  498. <div
  499. id="add-song-to-playlist"
  500. content="Add Song to Playlist"
  501. v-tippy
  502. >
  503. <div class="control has-addons">
  504. <button
  505. class="
  506. button
  507. is-primary
  508. "
  509. >
  510. <i
  511. class="
  512. material-icons
  513. "
  514. >
  515. playlist_add
  516. </i>
  517. </button>
  518. <button
  519. class="button"
  520. id="dropdown-toggle"
  521. >
  522. <i
  523. class="
  524. material-icons
  525. "
  526. >
  527. {{
  528. showPlaylistDropdown
  529. ? "expand_more"
  530. : "expand_less"
  531. }}
  532. </i>
  533. </button>
  534. </div>
  535. </div>
  536. </template>
  537. </add-to-playlist-dropdown>
  538. </div>
  539. <div id="right-buttons" v-else>
  540. <!-- Disabled Ratings (Like/Dislike) Buttons -->
  541. <div id="ratings" v-if="ratingsLoaded">
  542. <!-- Disabled Like Song Button -->
  543. <button
  544. class="button is-success disabled"
  545. id="like-song"
  546. content="Log in to like songs"
  547. v-tippy="{ theme: 'info' }"
  548. >
  549. <i
  550. class="
  551. material-icons
  552. icon-with-button
  553. "
  554. >thumb_up_alt</i
  555. >{{ currentSong.likes }}
  556. </button>
  557. <!-- Disabled Dislike Song Button -->
  558. <button
  559. class="button is-danger disabled"
  560. id="dislike-song"
  561. content="Log in to dislike songs"
  562. v-tippy="{ theme: 'info' }"
  563. >
  564. <i
  565. class="
  566. material-icons
  567. icon-with-button
  568. "
  569. >thumb_down_alt</i
  570. >{{ currentSong.dislikes }}
  571. </button>
  572. </div>
  573. <div id="ratings" v-else>
  574. <!-- Disabled Like Song Button -->
  575. <button
  576. class="button is-success disabled"
  577. id="like-song"
  578. content="Ratings have not been loaded yet"
  579. v-tippy="{ theme: 'info' }"
  580. >
  581. <i
  582. class="
  583. material-icons
  584. icon-with-button
  585. "
  586. >thumb_up_alt</i
  587. >
  588. </button>
  589. <!-- Disabled Dislike Song Button -->
  590. <button
  591. class="button is-danger disabled"
  592. id="dislike-song"
  593. content="Ratings have not been loaded yet"
  594. v-tippy="{ theme: 'info' }"
  595. >
  596. <i
  597. class="
  598. material-icons
  599. icon-with-button
  600. "
  601. >thumb_down_alt</i
  602. >
  603. </button>
  604. </div>
  605. <!-- Disabled Add Song To Playlist Button & Dropdown -->
  606. <div id="add-song-to-playlist">
  607. <div class="control has-addons">
  608. <button
  609. class="
  610. button
  611. is-primary
  612. disabled
  613. "
  614. content="Log in to add songs to playlist"
  615. v-tippy="{ theme: 'info' }"
  616. >
  617. <i class="material-icons"
  618. >queue</i
  619. >
  620. </button>
  621. </div>
  622. </div>
  623. </div>
  624. </div>
  625. </div>
  626. <p
  627. class="player-container nothing-here-text"
  628. v-if="noSong"
  629. >
  630. No song is currently playing
  631. </p>
  632. <div v-if="!noSong" id="current-next-row">
  633. <div
  634. id="currently-playing-container"
  635. class="quadrant"
  636. :class="{ 'no-currently-playing': noSong }"
  637. >
  638. <song-item
  639. :song="currentSong"
  640. :duration="false"
  641. :requested-by="
  642. station.type === 'community' &&
  643. station.partyMode === true
  644. "
  645. header="Currently Playing.."
  646. />
  647. <!-- <p v-else class="nothing-here-text">
  648. No song is currently playing
  649. </p> -->
  650. </div>
  651. <div
  652. v-if="nextSong"
  653. id="next-up-container"
  654. class="quadrant"
  655. >
  656. <song-item
  657. :song="nextSong"
  658. :duration="false"
  659. :requested-by="
  660. station.type === 'community' &&
  661. station.partyMode === true
  662. "
  663. header="Next Up.."
  664. />
  665. </div>
  666. </div>
  667. </div>
  668. </div>
  669. <request-song v-if="modals.requestSong" />
  670. <edit-playlist v-if="modals.editPlaylist" />
  671. <create-playlist v-if="modals.createPlaylist" />
  672. <manage-station
  673. v-if="modals.manageStation"
  674. :station-id="station._id"
  675. sector="station"
  676. />
  677. <report v-if="modals.report" />
  678. </div>
  679. <main-footer />
  680. </div>
  681. <edit-song v-if="modals.editSong" song-type="songs" sector="station" />
  682. <floating-box id="player-debug-box" ref="playerDebugBox">
  683. <template #body>
  684. <span><b>No song</b>: {{ noSong }}</span>
  685. <span><b>Song id</b>: {{ currentSong._id }}</span>
  686. <span><b>YouTube id</b>: {{ currentSong.youtubeId }}</span>
  687. <span><b>Duration</b>: {{ currentSong.duration }}</span>
  688. <span
  689. ><b>Skip duration</b>: {{ currentSong.skipDuration }}</span
  690. >
  691. <span><b>Loading</b>: {{ loading }}</span>
  692. <span><b>Can autoplay</b>: {{ canAutoplay }}</span>
  693. <span><b>Player ready</b>: {{ playerReady }}</span>
  694. <span
  695. ><b>Attempts to play video</b>:
  696. {{ attemptsToPlayVideo }}</span
  697. >
  698. <span
  699. ><b>Last time requested if can autoplay</b>:
  700. {{ lastTimeRequestedIfCanAutoplay }}</span
  701. >
  702. <span><b>Seeking</b>: {{ seeking }}</span>
  703. <span><b>Playback rate</b>: {{ playbackRate }}</span>
  704. <span><b>System difference</b>: {{ systemDifference }}</span>
  705. <span><b>Time before paused</b>: {{ timeBeforePause }}</span>
  706. <span><b>Time paused</b>: {{ timePaused }}</span>
  707. <span><b>Time elapsed</b>: {{ timeElapsed }}</span>
  708. <span><b>Volume slider value</b>: {{ volumeSliderValue }}</span>
  709. <span><b>Local paused</b>: {{ localPaused }}</span>
  710. <span><b>Station paused</b>: {{ stationPaused }}</span>
  711. <span
  712. ><b>Party playlists selected</b>: {{ partyPlaylists }}</span
  713. >
  714. <span><b>Skip votes loaded</b>: {{ skipVotesLoaded }}</span>
  715. <span
  716. ><b>Skip votes current</b>:
  717. {{
  718. currentSong.skipVotesCurrent === true ||
  719. currentSong.skipVotesCurrent === false
  720. ? currentSong.skipVotesCurrent
  721. : "N/A"
  722. }}</span
  723. >
  724. <span
  725. ><b>Skip votes</b>:
  726. {{ skipVotesLoaded ? currentSong.skipVotes : "N/A" }}</span
  727. >
  728. <span><b>Ratings loaded</b>: {{ ratingsLoaded }}</span>
  729. <span
  730. ><b>Ratings</b>:
  731. {{
  732. ratingsLoaded
  733. ? `${currentSong.likes} / ${currentSong.dislikes}`
  734. : "N/A"
  735. }}</span
  736. >
  737. <span><b>Own ratings loaded</b>: {{ ownRatingsLoaded }}</span>
  738. <span
  739. ><b>Own ratings</b>:
  740. {{
  741. ownRatingsLoaded
  742. ? `${currentSong.liked} / ${currentSong.disliked}`
  743. : "N/A"
  744. }}</span
  745. >
  746. </template>
  747. </floating-box>
  748. <Z404 v-if="!exists"></Z404>
  749. </div>
  750. </template>
  751. <script>
  752. import { mapState, mapActions, mapGetters } from "vuex";
  753. import { defineAsyncComponent } from "vue";
  754. import Toast from "toasters";
  755. import { ContentLoader } from "vue-content-loader";
  756. import aw from "@/aw";
  757. import ws from "@/ws";
  758. import keyboardShortcuts from "@/keyboardShortcuts";
  759. import MainHeader from "@/components/layout/MainHeader.vue";
  760. import MainFooter from "@/components/layout/MainFooter.vue";
  761. import FloatingBox from "@/components/FloatingBox.vue";
  762. import AddToPlaylistDropdown from "@/components/AddToPlaylistDropdown.vue";
  763. import SongItem from "@/components/SongItem.vue";
  764. import Z404 from "../404.vue";
  765. import utils from "../../../js/utils";
  766. import StationSidebar from "./Sidebar/index.vue";
  767. export default {
  768. components: {
  769. ContentLoader,
  770. MainHeader,
  771. MainFooter,
  772. RequestSong: defineAsyncComponent(() =>
  773. import("@/components/modals/RequestSong.vue")
  774. ),
  775. EditPlaylist: defineAsyncComponent(() =>
  776. import("@/components/modals/EditPlaylist")
  777. ),
  778. CreatePlaylist: defineAsyncComponent(() =>
  779. import("@/components/modals/CreatePlaylist.vue")
  780. ),
  781. ManageStation: defineAsyncComponent(() =>
  782. import("@/components/modals/ManageStation/index.vue")
  783. ),
  784. Report: defineAsyncComponent(() =>
  785. import("@/components/modals/Report.vue")
  786. ),
  787. Z404,
  788. FloatingBox,
  789. StationSidebar,
  790. AddToPlaylistDropdown,
  791. EditSong: defineAsyncComponent(() =>
  792. import("@/components/modals/EditSong")
  793. ),
  794. SongItem
  795. },
  796. data() {
  797. return {
  798. utils,
  799. isApple:
  800. navigator.platform.match(/iPhone|iPod|iPad/) ||
  801. navigator.vendor === "Apple Computer, Inc.",
  802. title: "Station",
  803. loading: true,
  804. exists: true,
  805. playerReady: false,
  806. player: undefined,
  807. timePaused: 0,
  808. muted: false,
  809. timeElapsed: "0:00",
  810. timeBeforePause: 0,
  811. systemDifference: 0,
  812. attemptsToPlayVideo: 0,
  813. canAutoplay: true,
  814. lastTimeRequestedIfCanAutoplay: 0,
  815. seeking: false,
  816. playbackRate: 1,
  817. volumeSliderValue: 0,
  818. showPlaylistDropdown: false,
  819. theme: "var(--primary-color)",
  820. seekerbarPercentage: 0,
  821. frontendDevMode: "production",
  822. activityWatchVideoDataInterval: null,
  823. activityWatchVideoLastStatus: "",
  824. activityWatchVideoLastYouTubeId: "",
  825. activityWatchVideoLastStartDuration: "",
  826. nextCurrentSong: null,
  827. editSongModalWatcher: null,
  828. beforeEditSongModalLocalPaused: null,
  829. socketConnected: null
  830. };
  831. },
  832. computed: {
  833. skipVotesLoaded() {
  834. return (
  835. !this.noSong &&
  836. Number.isInteger(this.currentSong.skipVotes) &&
  837. this.currentSong.skipVotes >= 0
  838. );
  839. },
  840. ratingsLoaded() {
  841. return (
  842. !this.noSong &&
  843. Number.isInteger(this.currentSong.likes) &&
  844. Number.isInteger(this.currentSong.dislikes) &&
  845. this.currentSong.likes >= 0 &&
  846. this.currentSong.dislikes >= 0
  847. );
  848. },
  849. ownRatingsLoaded() {
  850. return (
  851. !this.noSong &&
  852. typeof this.currentSong.liked === "boolean" &&
  853. typeof this.currentSong.disliked === "boolean"
  854. );
  855. },
  856. ...mapState("modalVisibility", {
  857. modals: state => state.modals
  858. }),
  859. ...mapState("modals/editSong", {
  860. video: state => state.video
  861. }),
  862. ...mapState("station", {
  863. station: state => state.station,
  864. currentSong: state => state.currentSong,
  865. nextSong: state => state.nextSong,
  866. songsList: state => state.songsList,
  867. stationPaused: state => state.stationPaused,
  868. localPaused: state => state.localPaused,
  869. noSong: state => state.noSong,
  870. partyPlaylists: state => state.partyPlaylists,
  871. includedPlaylists: state => state.includedPlaylists,
  872. excludedPlaylists: state => state.excludedPlaylists
  873. }),
  874. ...mapState({
  875. loggedIn: state => state.user.auth.loggedIn,
  876. userId: state => state.user.auth.userId,
  877. role: state => state.user.auth.role,
  878. nightmode: state => state.user.preferences.nightmode,
  879. autoSkipDisliked: state => state.user.preferences.autoSkipDisliked
  880. }),
  881. ...mapGetters({
  882. socket: "websockets/getSocket"
  883. })
  884. },
  885. async mounted() {
  886. this.editSongModalWatcher = this.$store.watch(
  887. state => state.modals.editSong.video.paused,
  888. paused => {
  889. if (paused && !this.beforeEditSongModalLocalPaused) {
  890. this.resumeLocalStation();
  891. } else if (!paused) {
  892. this.beforeEditSongModalLocalPaused = this.localPaused;
  893. this.pauseLocalStation();
  894. }
  895. }
  896. );
  897. window.scrollTo(0, 0);
  898. Date.currently = () => new Date().getTime() + this.systemDifference;
  899. this.stationIdentifier = this.$route.params.id;
  900. window.stationInterval = 0;
  901. this.activityWatchVideoDataInterval = setInterval(() => {
  902. this.sendActivityWatchVideoData();
  903. }, 1000);
  904. if (this.socket.readyState === 1) this.join();
  905. ws.onConnect(() => {
  906. this.socketConnected = true;
  907. clearTimeout(window.stationNextSongTimeout);
  908. this.join();
  909. });
  910. ws.onDisconnect(true, () => {
  911. this.socketConnected = false;
  912. const { currentSong } = this.currentSong;
  913. if (this.nextSong)
  914. this.setNextCurrentSong(
  915. {
  916. currentSong: this.nextSong,
  917. startedAt: Date.now() + this.getTimeRemaining(),
  918. paused: false,
  919. timePaused: 0
  920. },
  921. true
  922. );
  923. else
  924. this.setNextCurrentSong(
  925. {
  926. currentSong: null,
  927. startedAt: 0,
  928. paused: false,
  929. timePaused: 0,
  930. pausedAt: 0
  931. },
  932. true
  933. );
  934. window.stationNextSongTimeout = setTimeout(() => {
  935. if (!this.noSong && this.currentSong._id === currentSong._id)
  936. this.skipSong("window.stationNextSongTimeout 2");
  937. }, this.getTimeRemaining());
  938. });
  939. this.frontendDevMode = await lofig.get("mode");
  940. this.socket.dispatch(
  941. "stations.existsByName",
  942. this.stationIdentifier,
  943. res => {
  944. if (res.status === "error" || !res.data.exists) {
  945. // station identifier may be using stationid instead
  946. this.socket.dispatch(
  947. "stations.existsById",
  948. this.stationIdentifier,
  949. res => {
  950. if (res.status === "error" || !res.data.exists) {
  951. this.loading = false;
  952. this.exists = false;
  953. }
  954. }
  955. );
  956. }
  957. }
  958. );
  959. this.socket.on("event:station.nextSong", res => {
  960. const { currentSong, startedAt, paused, timePaused } = res.data;
  961. this.setCurrentSong({
  962. currentSong,
  963. startedAt,
  964. paused,
  965. timePaused,
  966. pausedAt: 0
  967. });
  968. });
  969. this.socket.on("event:station.pause", res => {
  970. this.pausedAt = res.data.pausedAt;
  971. this.updateStationPaused(true);
  972. this.pauseLocalPlayer();
  973. clearTimeout(window.stationNextSongTimeout);
  974. });
  975. this.socket.on("event:station.resume", res => {
  976. this.timePaused = res.data.timePaused;
  977. this.updateStationPaused(false);
  978. if (!this.localPaused) this.resumeLocalPlayer();
  979. });
  980. this.socket.on("event:station.deleted", () => {
  981. window.location.href = "/";
  982. return true;
  983. });
  984. this.socket.on("event:song.liked", res => {
  985. if (!this.noSong) {
  986. if (res.data.youtubeId === this.currentSong.youtubeId) {
  987. this.updateCurrentSongRatings(res.data);
  988. }
  989. }
  990. });
  991. this.socket.on("event:song.disliked", res => {
  992. if (!this.noSong) {
  993. if (res.data.youtubeId === this.currentSong.youtubeId) {
  994. this.updateCurrentSongRatings(res.data);
  995. }
  996. }
  997. });
  998. this.socket.on("event:song.unliked", res => {
  999. if (!this.noSong) {
  1000. if (res.data.youtubeId === this.currentSong.youtubeId) {
  1001. this.updateCurrentSongRatings(res.data);
  1002. }
  1003. }
  1004. });
  1005. this.socket.on("event:song.undisliked", res => {
  1006. if (!this.noSong) {
  1007. if (res.data.youtubeId === this.currentSong.youtubeId) {
  1008. this.updateCurrentSongRatings(res.data);
  1009. }
  1010. }
  1011. });
  1012. this.socket.on("event:song.ratings.updated", res => {
  1013. if (!this.noSong) {
  1014. if (res.data.youtubeId === this.currentSong.youtubeId) {
  1015. this.updateOwnCurrentSongRatings(res.data);
  1016. }
  1017. }
  1018. });
  1019. this.socket.on("event:station.queue.updated", res => {
  1020. this.updateSongsList(res.data.queue);
  1021. let nextSong = null;
  1022. if (this.songsList[0])
  1023. nextSong = this.songsList[0].youtubeId
  1024. ? this.songsList[0]
  1025. : null;
  1026. this.updateNextSong(nextSong);
  1027. this.addPartyPlaylistSongToQueue();
  1028. });
  1029. this.socket.on("event:station.queue.song.repositioned", res => {
  1030. this.repositionSongInList(res.data.song);
  1031. let nextSong = null;
  1032. if (this.songsList[0])
  1033. nextSong = this.songsList[0].youtubeId
  1034. ? this.songsList[0]
  1035. : null;
  1036. this.updateNextSong(nextSong);
  1037. });
  1038. this.socket.on("event:station.voteSkipSong", () => {
  1039. if (this.currentSong)
  1040. this.updateCurrentSongSkipVotes({
  1041. skipVotes: this.currentSong.skipVotes + 1,
  1042. skipVotesCurrent: null
  1043. });
  1044. });
  1045. this.socket.on("event:privatePlaylist.selected", res => {
  1046. if (this.station.type === "community")
  1047. this.station.privatePlaylist = res.data.playlistId;
  1048. });
  1049. this.socket.on("event:privatePlaylist.deselected", () => {
  1050. if (this.station.type === "community")
  1051. this.station.privatePlaylist = null;
  1052. });
  1053. this.socket.on("event:station.partyMode.updated", res => {
  1054. if (this.station.type === "community")
  1055. this.station.partyMode = res.data.partyMode;
  1056. });
  1057. this.socket.on("event:station.theme.updated", res => {
  1058. const { theme } = res.data;
  1059. this.station.theme = theme;
  1060. document.body.style.cssText = `--primary-color: var(--${theme})`;
  1061. });
  1062. this.socket.on("event:station.name.updated", async res => {
  1063. this.station.name = res.data.name;
  1064. await this.$router.push(
  1065. `${res.data.name}?${Object.keys(this.$route.query)
  1066. .map(
  1067. key =>
  1068. `${encodeURIComponent(key)}=${encodeURIComponent(
  1069. this.$route.query[key]
  1070. )}`
  1071. )
  1072. .join("&")}`
  1073. );
  1074. // eslint-disable-next-line no-restricted-globals
  1075. history.replaceState({ ...history.state, ...{} }, null);
  1076. });
  1077. this.socket.on("event:station.displayName.updated", res => {
  1078. this.station.displayName = res.data.displayName;
  1079. });
  1080. this.socket.on("event:station.description.updated", res => {
  1081. this.station.description = res.data.description;
  1082. });
  1083. // this.socket.on("event:newOfficialPlaylist", res => {
  1084. // if (this.station.type === "official")
  1085. // this.updateSongsList(res.data.playlist);
  1086. // });
  1087. this.socket.on("event:station.users.updated", res =>
  1088. this.updateUsers(res.data.users)
  1089. );
  1090. this.socket.on("event:station.userCount.updated", res =>
  1091. this.updateUserCount(res.data.userCount)
  1092. );
  1093. this.socket.on("event:station.queue.lock.toggled", res => {
  1094. this.station.locked = res.data.locked;
  1095. });
  1096. this.socket.on("event:user.station.favorited", res => {
  1097. if (res.data.stationId === this.station._id)
  1098. this.updateIfStationIsFavorited({ isFavorited: true });
  1099. });
  1100. this.socket.on("event:user.station.unfavorited", res => {
  1101. if (res.data.stationId === this.station._id)
  1102. this.updateIfStationIsFavorited({ isFavorited: false });
  1103. });
  1104. if (JSON.parse(localStorage.getItem("muted"))) {
  1105. this.muted = true;
  1106. this.player.setVolume(0);
  1107. this.volumeSliderValue = 0 * 100;
  1108. } else {
  1109. let volume = parseFloat(localStorage.getItem("volume"));
  1110. volume =
  1111. typeof volume === "number" && !Number.isNaN(volume)
  1112. ? volume
  1113. : 20;
  1114. localStorage.setItem("volume", volume);
  1115. this.volumeSliderValue = volume * 100;
  1116. }
  1117. },
  1118. beforeUnmount() {
  1119. document.body.style.cssText = "";
  1120. /** Reset Songslist */
  1121. this.updateSongsList([]);
  1122. const shortcutNames = [
  1123. "station.pauseResume",
  1124. "station.skipStation",
  1125. "station.lowerVolumeLarge",
  1126. "station.lowerVolumeSmall",
  1127. "station.increaseVolumeLarge",
  1128. "station.increaseVolumeSmall",
  1129. "station.toggleDebug"
  1130. ];
  1131. shortcutNames.forEach(shortcutName => {
  1132. keyboardShortcuts.unregisterShortcut(shortcutName);
  1133. });
  1134. this.editSongModalWatcher(); // removes the watcher
  1135. clearInterval(this.activityWatchVideoDataInterval);
  1136. clearTimeout(window.stationNextSongTimeout);
  1137. this.socket.dispatch("stations.leave", this.station._id, () => {});
  1138. this.leaveStation();
  1139. },
  1140. methods: {
  1141. isOwnerOnly() {
  1142. return this.loggedIn && this.userId === this.station.owner;
  1143. },
  1144. isAdminOnly() {
  1145. return this.loggedIn && this.role === "admin";
  1146. },
  1147. isOwnerOrAdmin() {
  1148. return this.isOwnerOnly() || this.isAdminOnly();
  1149. },
  1150. removeFromQueue(youtubeId) {
  1151. window.socket.dispatch(
  1152. "stations.removeFromQueue",
  1153. this.station._id,
  1154. youtubeId,
  1155. res => {
  1156. if (res.status === "success") {
  1157. new Toast("Successfully removed song from the queue.");
  1158. } else new Toast(res.message);
  1159. }
  1160. );
  1161. },
  1162. setNextCurrentSong(nextCurrentSong, skipSkipCheck = false) {
  1163. this.nextCurrentSong = nextCurrentSong;
  1164. // If skipSkipCheck is true, it won't try to skip the song
  1165. if (this.getTimeRemaining() <= 0 && !skipSkipCheck) {
  1166. this.skipSong();
  1167. }
  1168. },
  1169. skipSong() {
  1170. if (this.nextCurrentSong && this.nextCurrentSong.currentSong) {
  1171. const songsList = this.songsList.concat([]);
  1172. if (
  1173. songsList.length > 0 &&
  1174. songsList[0].youtubeId ===
  1175. this.nextCurrentSong.currentSong.youtubeId
  1176. ) {
  1177. songsList.splice(0, 1);
  1178. this.updateSongsList(songsList);
  1179. }
  1180. this.setCurrentSong(this.nextCurrentSong);
  1181. } else {
  1182. this.setCurrentSong({
  1183. currentSong: null,
  1184. startedAt: 0,
  1185. paused: this.stationPaused,
  1186. timePaused: 0,
  1187. pausedAt: 0
  1188. });
  1189. }
  1190. },
  1191. setCurrentSong(data) {
  1192. const { currentSong, startedAt, paused, timePaused, pausedAt } =
  1193. data;
  1194. if (currentSong) {
  1195. if (!currentSong.skipDuration || currentSong.skipDuration < 0)
  1196. currentSong.skipDuration = 0;
  1197. if (!currentSong.duration || currentSong.duration < 0)
  1198. currentSong.duration = 0;
  1199. }
  1200. this.updateCurrentSong(currentSong || {});
  1201. let nextSong = null;
  1202. if (this.songsList[0])
  1203. nextSong = this.songsList[0].youtubeId
  1204. ? this.songsList[0]
  1205. : null;
  1206. this.updateNextSong(nextSong);
  1207. this.setNextCurrentSong(
  1208. {
  1209. currentSong: null,
  1210. startedAt: 0,
  1211. paused,
  1212. timePaused: 0,
  1213. pausedAt: 0
  1214. },
  1215. true
  1216. );
  1217. clearTimeout(window.stationNextSongTimeout);
  1218. this.startedAt = startedAt;
  1219. this.updateStationPaused(paused);
  1220. this.timePaused = timePaused;
  1221. this.pausedAt = pausedAt;
  1222. if (currentSong) {
  1223. this.updateNoSong(false);
  1224. if (!this.playerReady) this.youtubeReady();
  1225. else this.playVideo();
  1226. // If the station is playing and the backend is not connected, set the next song to skip to after this song and set a timer to skip
  1227. if (!this.stationPaused && !this.socketConnected) {
  1228. if (this.nextSong)
  1229. this.setNextCurrentSong(
  1230. {
  1231. currentSong: this.nextSong,
  1232. startedAt: Date.now() + this.getTimeRemaining(),
  1233. paused: false,
  1234. timePaused: 0
  1235. },
  1236. true
  1237. );
  1238. else
  1239. this.setNextCurrentSong(
  1240. {
  1241. currentSong: null,
  1242. startedAt: 0,
  1243. paused: false,
  1244. timePaused: 0,
  1245. pausedAt: 0
  1246. },
  1247. true
  1248. );
  1249. window.stationNextSongTimeout = setTimeout(() => {
  1250. if (
  1251. !this.noSong &&
  1252. this.currentSong._id === currentSong._id
  1253. )
  1254. this.skipSong("window.stationNextSongTimeout 1");
  1255. }, this.getTimeRemaining());
  1256. }
  1257. const currentSongId = this.currentSong._id;
  1258. this.socket.dispatch(
  1259. "stations.getSkipVotes",
  1260. this.station._id,
  1261. currentSongId,
  1262. res => {
  1263. if (res.status === "success") {
  1264. const { skipVotes, skipVotesCurrent } = res.data;
  1265. if (
  1266. !this.noSong &&
  1267. this.currentSong._id === currentSongId
  1268. ) {
  1269. this.updateCurrentSongSkipVotes({
  1270. skipVotes,
  1271. skipVotesCurrent
  1272. });
  1273. }
  1274. }
  1275. }
  1276. );
  1277. this.socket.dispatch(
  1278. "songs.getSongRatings",
  1279. currentSong._id,
  1280. res => {
  1281. if (currentSong._id === this.currentSong._id) {
  1282. const { likes, dislikes } = res.data;
  1283. this.updateCurrentSongRatings({ likes, dislikes });
  1284. }
  1285. }
  1286. );
  1287. if (this.loggedIn) {
  1288. this.socket.dispatch(
  1289. "songs.getOwnSongRatings",
  1290. currentSong.youtubeId,
  1291. res => {
  1292. console.log("getOwnSongRatings", res);
  1293. if (
  1294. res.status === "success" &&
  1295. this.currentSong.youtubeId ===
  1296. res.data.youtubeId
  1297. ) {
  1298. this.updateOwnCurrentSongRatings(res.data);
  1299. if (
  1300. this.autoSkipDisliked &&
  1301. res.data.disliked === true
  1302. ) {
  1303. this.voteSkipStation();
  1304. new Toast(
  1305. "Automatically voted to skip disliked song."
  1306. );
  1307. }
  1308. }
  1309. }
  1310. );
  1311. }
  1312. } else {
  1313. if (this.playerReady) this.player.pauseVideo();
  1314. this.updateNoSong(true);
  1315. }
  1316. this.calculateTimeElapsed();
  1317. this.resizeSeekerbar();
  1318. },
  1319. youtubeReady() {
  1320. if (!this.player) {
  1321. this.player = new window.YT.Player("stationPlayer", {
  1322. height: 270,
  1323. width: 480,
  1324. videoId: this.currentSong.youtubeId,
  1325. host: "https://www.youtube-nocookie.com",
  1326. startSeconds:
  1327. this.getTimeElapsed() / 1000 +
  1328. this.currentSong.skipDuration,
  1329. playerVars: {
  1330. controls: 0,
  1331. iv_load_policy: 3,
  1332. rel: 0,
  1333. showinfo: 0,
  1334. disablekb: 1,
  1335. playsinline: 1
  1336. },
  1337. events: {
  1338. onReady: () => {
  1339. this.playerReady = true;
  1340. let volume = parseInt(
  1341. localStorage.getItem("volume")
  1342. );
  1343. volume = typeof volume === "number" ? volume : 20;
  1344. this.player.setVolume(volume);
  1345. if (volume > 0) this.player.unMute();
  1346. if (this.muted) this.player.mute();
  1347. this.playVideo();
  1348. // on ios, playback will be forcibly paused locally
  1349. if (this.isApple) {
  1350. this.updateLocalPaused(true);
  1351. new Toast(
  1352. "Please click play manually to use Musare on iOS."
  1353. );
  1354. }
  1355. },
  1356. onError: err => {
  1357. console.log("error with youtube video", err);
  1358. if (err.data === 150 && this.loggedIn) {
  1359. new Toast(
  1360. "Automatically voted to skip as this song isn't available for you."
  1361. );
  1362. // automatically vote to skip
  1363. this.voteSkipStation();
  1364. // persistent message while song is playing
  1365. const persistentToast = new Toast({
  1366. content:
  1367. "This song is unavailable for you, but is playing for everyone else.",
  1368. persistent: true
  1369. });
  1370. // save current song id
  1371. const erroredYoutubeId =
  1372. this.currentSong.youtubeId;
  1373. // remove persistent toast if video has finished
  1374. window.isSongErroredInterval = setInterval(
  1375. () => {
  1376. if (
  1377. this.currentSong.youtubeId !==
  1378. erroredYoutubeId
  1379. ) {
  1380. persistentToast.destroy();
  1381. clearInterval(
  1382. window.isSongErroredInterval
  1383. );
  1384. }
  1385. },
  1386. 150
  1387. );
  1388. } else {
  1389. new Toast(
  1390. "There has been an error with the YouTube Embed"
  1391. );
  1392. }
  1393. },
  1394. onStateChange: event => {
  1395. if (
  1396. event.data === window.YT.PlayerState.PLAYING &&
  1397. this.videoLoading === true
  1398. ) {
  1399. this.videoLoading = false;
  1400. this.player.seekTo(
  1401. this.getTimeElapsed() / 1000 +
  1402. this.currentSong.skipDuration,
  1403. true
  1404. );
  1405. this.canAutoplay = true;
  1406. if (this.localPaused || this.stationPaused)
  1407. this.player.pauseVideo();
  1408. } else if (
  1409. event.data === window.YT.PlayerState.PLAYING &&
  1410. (this.localPaused || this.stationPaused)
  1411. ) {
  1412. this.player.seekTo(
  1413. this.timeBeforePause / 1000,
  1414. true
  1415. );
  1416. this.player.pauseVideo();
  1417. } else if (
  1418. event.data === window.YT.PlayerState.PLAYING &&
  1419. this.seeking === true
  1420. )
  1421. this.seeking = false;
  1422. if (
  1423. event.data === window.YT.PlayerState.PAUSED &&
  1424. !this.localPaused &&
  1425. !this.stationPaused &&
  1426. !this.noSong &&
  1427. this.player.getDuration() / 1000 <
  1428. this.currentSong.duration
  1429. ) {
  1430. this.player.seekTo(
  1431. this.getTimeElapsed() / 1000 +
  1432. this.currentSong.skipDuration,
  1433. true
  1434. );
  1435. this.player.playVideo();
  1436. }
  1437. }
  1438. }
  1439. });
  1440. }
  1441. },
  1442. getTimeElapsed() {
  1443. if (this.currentSong) {
  1444. let { timePaused } = this;
  1445. if (this.stationPaused)
  1446. timePaused += Date.currently() - this.pausedAt;
  1447. return Date.currently() - this.startedAt - timePaused;
  1448. }
  1449. return 0;
  1450. },
  1451. getTimeRemaining() {
  1452. if (this.currentSong) {
  1453. return this.currentSong.duration * 1000 - this.getTimeElapsed();
  1454. }
  1455. return 0;
  1456. },
  1457. playVideo() {
  1458. if (this.playerReady) {
  1459. this.videoLoading = true;
  1460. this.player.loadVideoById(
  1461. this.currentSong.youtubeId,
  1462. this.getTimeElapsed() / 1000 + this.currentSong.skipDuration
  1463. );
  1464. if (window.stationInterval !== 0)
  1465. clearInterval(window.stationInterval);
  1466. window.stationInterval = setInterval(() => {
  1467. if (!this.stationPaused) {
  1468. this.resizeSeekerbar();
  1469. this.calculateTimeElapsed();
  1470. }
  1471. }, 150);
  1472. }
  1473. },
  1474. resizeSeekerbar() {
  1475. this.seekerbarPercentage = parseFloat(
  1476. (this.getTimeElapsed() / 1000 / this.currentSong.duration) * 100
  1477. );
  1478. },
  1479. calculateTimeElapsed() {
  1480. if (
  1481. this.playerReady &&
  1482. this.currentSong &&
  1483. this.player.getPlayerState() === -1
  1484. ) {
  1485. if (!this.canAutoplay) {
  1486. if (
  1487. Date.now() - this.lastTimeRequestedIfCanAutoplay >
  1488. 2000
  1489. ) {
  1490. this.lastTimeRequestedIfCanAutoplay = Date.now();
  1491. window.canAutoplay.video().then(({ result }) => {
  1492. if (result) {
  1493. this.attemptsToPlayVideo = 0;
  1494. this.canAutoplay = true;
  1495. } else {
  1496. this.canAutoplay = false;
  1497. }
  1498. });
  1499. }
  1500. } else {
  1501. this.player.playVideo();
  1502. this.attemptsToPlayVideo += 1;
  1503. }
  1504. }
  1505. if (
  1506. !this.stationPaused &&
  1507. !this.localPaused &&
  1508. this.playerReady &&
  1509. !this.isApple
  1510. ) {
  1511. const timeElapsed = this.getTimeElapsed();
  1512. const currentPlayerTime =
  1513. Math.max(
  1514. this.player.getCurrentTime() -
  1515. this.currentSong.skipDuration,
  1516. 0
  1517. ) * 1000;
  1518. const difference = timeElapsed - currentPlayerTime;
  1519. let playbackRate = 1;
  1520. if (difference < -2000) {
  1521. if (!this.seeking) {
  1522. this.seeking = true;
  1523. this.player.seekTo(
  1524. this.getTimeElapsed() / 1000 +
  1525. this.currentSong.skipDuration
  1526. );
  1527. }
  1528. } else if (difference < -200) {
  1529. // console.log("Difference0.8");
  1530. playbackRate = 0.8;
  1531. } else if (difference < -50) {
  1532. // console.log("Difference0.9");
  1533. playbackRate = 0.9;
  1534. } else if (difference < -25) {
  1535. // console.log("Difference0.99");
  1536. playbackRate = 0.95;
  1537. } else if (difference > 2000) {
  1538. if (!this.seeking) {
  1539. this.seeking = true;
  1540. this.player.seekTo(
  1541. this.getTimeElapsed() / 1000 +
  1542. this.currentSong.skipDuration
  1543. );
  1544. }
  1545. } else if (difference > 200) {
  1546. // console.log("Difference1.2");
  1547. playbackRate = 1.2;
  1548. } else if (difference > 50) {
  1549. // console.log("Difference1.1");
  1550. playbackRate = 1.1;
  1551. } else if (difference > 25) {
  1552. // console.log("Difference1.01");
  1553. playbackRate = 1.05;
  1554. } else if (this.player.getPlaybackRate !== 1.0) {
  1555. // console.log("NDifference1.0");
  1556. this.player.setPlaybackRate(1.0);
  1557. }
  1558. if (this.playbackRate !== playbackRate) {
  1559. this.player.setPlaybackRate(playbackRate);
  1560. this.playbackRate = playbackRate;
  1561. }
  1562. }
  1563. /* if (this.currentTime !== undefined && this.paused) {
  1564. this.timePaused += Date.currently() - this.currentTime;
  1565. this.currentTime = undefined;
  1566. } */
  1567. let { timePaused } = this;
  1568. if (this.stationPaused)
  1569. timePaused += Date.currently() - this.pausedAt;
  1570. const duration =
  1571. (Date.currently() - this.startedAt - timePaused) / 1000;
  1572. const songDuration = this.currentSong.duration;
  1573. if (songDuration <= duration) this.player.pauseVideo();
  1574. if (duration <= songDuration)
  1575. this.timeElapsed = utils.formatTime(duration);
  1576. },
  1577. toggleLock() {
  1578. window.socket.dispatch(
  1579. "stations.toggleLock",
  1580. this.station._id,
  1581. res => {
  1582. if (res.status === "success") {
  1583. new Toast("Successfully toggled the queue lock.");
  1584. } else new Toast(res.message);
  1585. }
  1586. );
  1587. },
  1588. changeVolume() {
  1589. const volume = this.volumeSliderValue;
  1590. localStorage.setItem("volume", volume / 100);
  1591. if (this.playerReady) {
  1592. this.player.setVolume(volume / 100);
  1593. if (volume > 0) {
  1594. this.player.unMute();
  1595. localStorage.setItem("muted", false);
  1596. this.muted = false;
  1597. }
  1598. }
  1599. },
  1600. resumeLocalStation() {
  1601. this.updateLocalPaused(false);
  1602. if (!this.stationPaused) this.resumeLocalPlayer();
  1603. },
  1604. pauseLocalStation() {
  1605. this.updateLocalPaused(true);
  1606. this.pauseLocalPlayer();
  1607. },
  1608. resumeLocalPlayer() {
  1609. if (!this.noSong) {
  1610. if (this.playerReady) {
  1611. this.player.seekTo(
  1612. this.getTimeElapsed() / 1000 +
  1613. this.currentSong.skipDuration
  1614. );
  1615. this.player.playVideo();
  1616. }
  1617. }
  1618. },
  1619. pauseLocalPlayer() {
  1620. if (!this.noSong) {
  1621. this.timeBeforePause = this.getTimeElapsed();
  1622. if (this.playerReady) this.player.pauseVideo();
  1623. }
  1624. },
  1625. skipStation() {
  1626. this.socket.dispatch(
  1627. "stations.forceSkip",
  1628. this.station._id,
  1629. data => {
  1630. if (data.status !== "success")
  1631. new Toast(`Error: ${data.message}`);
  1632. else
  1633. new Toast(
  1634. "Successfully skipped the station's current song."
  1635. );
  1636. }
  1637. );
  1638. },
  1639. voteSkipStation() {
  1640. this.socket.dispatch(
  1641. "stations.voteSkip",
  1642. this.station._id,
  1643. data => {
  1644. if (data.status !== "success")
  1645. new Toast(`Error: ${data.message}`);
  1646. else
  1647. new Toast(
  1648. "Successfully voted to skip the current song."
  1649. );
  1650. }
  1651. );
  1652. },
  1653. resumeStation() {
  1654. this.socket.dispatch("stations.resume", this.station._id, data => {
  1655. if (data.status !== "success")
  1656. new Toast(`Error: ${data.message}`);
  1657. else new Toast("Successfully resumed the station.");
  1658. });
  1659. },
  1660. pauseStation() {
  1661. this.socket.dispatch("stations.pause", this.station._id, data => {
  1662. if (data.status !== "success")
  1663. new Toast(`Error: ${data.message}`);
  1664. else new Toast("Successfully paused the station.");
  1665. });
  1666. },
  1667. toggleMute() {
  1668. if (this.playerReady) {
  1669. const previousVolume = parseFloat(
  1670. localStorage.getItem("volume")
  1671. );
  1672. const volume =
  1673. this.player.getVolume() * 100 <= 0 ? previousVolume : 0;
  1674. this.muted = !this.muted;
  1675. localStorage.setItem("muted", this.muted);
  1676. this.volumeSliderValue = volume * 100;
  1677. this.player.setVolume(volume);
  1678. if (!this.muted) localStorage.setItem("volume", volume);
  1679. }
  1680. },
  1681. increaseVolume() {
  1682. if (this.playerReady) {
  1683. const previousVolume = parseInt(localStorage.getItem("volume"));
  1684. let volume = previousVolume + 5;
  1685. if (previousVolume === 0) {
  1686. this.muted = false;
  1687. localStorage.setItem("muted", false);
  1688. }
  1689. if (volume > 100) volume = 100;
  1690. this.volumeSliderValue = volume * 100;
  1691. this.player.setVolume(volume);
  1692. localStorage.setItem("volume", volume);
  1693. }
  1694. },
  1695. toggleLike() {
  1696. if (this.currentSong.liked)
  1697. this.socket.dispatch(
  1698. "songs.unlike",
  1699. this.currentSong.youtubeId,
  1700. res => {
  1701. if (res.status !== "success")
  1702. new Toast(`Error: ${res.message}`);
  1703. }
  1704. );
  1705. else
  1706. this.socket.dispatch(
  1707. "songs.like",
  1708. this.currentSong.youtubeId,
  1709. res => {
  1710. if (res.status !== "success")
  1711. new Toast(`Error: ${res.message}`);
  1712. }
  1713. );
  1714. },
  1715. toggleDislike() {
  1716. if (this.currentSong.disliked)
  1717. return this.socket.dispatch(
  1718. "songs.undislike",
  1719. this.currentSong.youtubeId,
  1720. res => {
  1721. if (res.status !== "success")
  1722. new Toast(`Error: ${res.message}`);
  1723. }
  1724. );
  1725. return this.socket.dispatch(
  1726. "songs.dislike",
  1727. this.currentSong.youtubeId,
  1728. res => {
  1729. if (res.status !== "success")
  1730. new Toast(`Error: ${res.message}`);
  1731. }
  1732. );
  1733. },
  1734. addPartyPlaylistSongToQueue() {
  1735. let isInQueue = false;
  1736. if (
  1737. this.station.type === "community" &&
  1738. this.station.partyMode === true
  1739. ) {
  1740. this.songsList.forEach(queueSong => {
  1741. if (queueSong.requestedBy === this.userId) isInQueue = true;
  1742. });
  1743. if (!isInQueue && this.partyPlaylists.length > 0) {
  1744. const selectedPlaylist =
  1745. this.partyPlaylists[
  1746. Math.floor(
  1747. Math.random() * this.partyPlaylists.length
  1748. )
  1749. ];
  1750. if (
  1751. selectedPlaylist._id &&
  1752. selectedPlaylist.songs.length > 0
  1753. ) {
  1754. const selectedSong =
  1755. selectedPlaylist.songs[
  1756. Math.floor(
  1757. Math.random() *
  1758. selectedPlaylist.songs.length
  1759. )
  1760. ];
  1761. if (selectedSong.youtubeId) {
  1762. this.socket.dispatch(
  1763. "stations.addToQueue",
  1764. this.station._id,
  1765. selectedSong.youtubeId,
  1766. data => {
  1767. if (data.status !== "success")
  1768. new Toast("Error auto queueing song");
  1769. }
  1770. );
  1771. }
  1772. }
  1773. }
  1774. }
  1775. },
  1776. togglePlayerDebugBox() {
  1777. this.$refs.playerDebugBox.toggleBox();
  1778. },
  1779. resetPlayerDebugBox() {
  1780. this.$refs.playerDebugBox.resetBox();
  1781. },
  1782. join() {
  1783. this.socket.dispatch(
  1784. "stations.join",
  1785. this.stationIdentifier,
  1786. res => {
  1787. if (res.status === "success") {
  1788. setTimeout(() => {
  1789. this.loading = false;
  1790. }, 1000); // prevents popping in of youtube embed etc.
  1791. const {
  1792. _id,
  1793. displayName,
  1794. name,
  1795. description,
  1796. privacy,
  1797. locked,
  1798. partyMode,
  1799. owner,
  1800. privatePlaylist,
  1801. includedPlaylists,
  1802. excludedPlaylists,
  1803. type,
  1804. genres,
  1805. blacklistedGenres,
  1806. isFavorited,
  1807. theme
  1808. } = res.data;
  1809. // change url to use station name instead of station id
  1810. if (name !== this.stationIdentifier) {
  1811. // eslint-disable-next-line no-restricted-globals
  1812. this.$router.replace(name);
  1813. }
  1814. this.joinStation({
  1815. _id,
  1816. name,
  1817. displayName,
  1818. description,
  1819. privacy,
  1820. locked,
  1821. partyMode,
  1822. owner,
  1823. privatePlaylist,
  1824. includedPlaylists,
  1825. excludedPlaylists,
  1826. type,
  1827. genres,
  1828. blacklistedGenres,
  1829. isFavorited,
  1830. theme
  1831. });
  1832. document.body.style.cssText = `--primary-color: var(--${res.data.theme})`;
  1833. this.setCurrentSong({
  1834. currentSong: res.data.currentSong,
  1835. startedAt: res.data.startedAt,
  1836. paused: res.data.paused,
  1837. timePaused: res.data.timePaused,
  1838. pausedAt: res.data.pausedAt
  1839. });
  1840. this.updateUserCount(res.data.userCount);
  1841. this.updateUsers(res.data.users);
  1842. this.socket.dispatch(
  1843. "stations.getStationIncludedPlaylistsById",
  1844. this.station._id,
  1845. res => {
  1846. if (res.status === "success") {
  1847. this.setIncludedPlaylists(
  1848. res.data.playlists
  1849. );
  1850. }
  1851. }
  1852. );
  1853. this.socket.dispatch(
  1854. "stations.getStationExcludedPlaylistsById",
  1855. this.station._id,
  1856. res => {
  1857. if (res.status === "success") {
  1858. this.setExcludedPlaylists(
  1859. res.data.playlists
  1860. );
  1861. }
  1862. }
  1863. );
  1864. this.socket.dispatch("stations.getQueue", _id, res => {
  1865. if (res.status === "success") {
  1866. const { queue } = res.data;
  1867. this.updateSongsList(queue);
  1868. const [nextSong] = queue;
  1869. this.updateNextSong(nextSong);
  1870. }
  1871. });
  1872. if (this.isOwnerOrAdmin()) {
  1873. keyboardShortcuts.registerShortcut(
  1874. "station.pauseResume",
  1875. {
  1876. keyCode: 32,
  1877. shift: false,
  1878. ctrl: true,
  1879. preventDefault: true,
  1880. handler: () => {
  1881. if (this.stationPaused)
  1882. this.resumeStation();
  1883. else this.pauseStation();
  1884. }
  1885. }
  1886. );
  1887. keyboardShortcuts.registerShortcut(
  1888. "station.skipStation",
  1889. {
  1890. keyCode: 39,
  1891. shift: false,
  1892. ctrl: true,
  1893. preventDefault: true,
  1894. handler: () => {
  1895. this.skipStation();
  1896. }
  1897. }
  1898. );
  1899. }
  1900. keyboardShortcuts.registerShortcut(
  1901. "station.lowerVolumeLarge",
  1902. {
  1903. keyCode: 40,
  1904. shift: false,
  1905. ctrl: true,
  1906. preventDefault: true,
  1907. handler: () => {
  1908. this.volumeSliderValue -= 1000;
  1909. this.changeVolume();
  1910. }
  1911. }
  1912. );
  1913. keyboardShortcuts.registerShortcut(
  1914. "station.lowerVolumeSmall",
  1915. {
  1916. keyCode: 40,
  1917. shift: true,
  1918. ctrl: true,
  1919. preventDefault: true,
  1920. handler: () => {
  1921. this.volumeSliderValue -= 100;
  1922. this.changeVolume();
  1923. }
  1924. }
  1925. );
  1926. keyboardShortcuts.registerShortcut(
  1927. "station.increaseVolumeLarge",
  1928. {
  1929. keyCode: 38,
  1930. shift: false,
  1931. ctrl: true,
  1932. preventDefault: true,
  1933. handler: () => {
  1934. this.volumeSliderValue += 1000;
  1935. this.changeVolume();
  1936. }
  1937. }
  1938. );
  1939. keyboardShortcuts.registerShortcut(
  1940. "station.increaseVolumeSmall",
  1941. {
  1942. keyCode: 38,
  1943. shift: true,
  1944. ctrl: true,
  1945. preventDefault: true,
  1946. handler: () => {
  1947. this.volumeSliderValue += 100;
  1948. this.changeVolume();
  1949. }
  1950. }
  1951. );
  1952. keyboardShortcuts.registerShortcut(
  1953. "station.toggleDebug",
  1954. {
  1955. keyCode: 68,
  1956. shift: false,
  1957. ctrl: true,
  1958. preventDefault: true,
  1959. handler: () => {
  1960. this.togglePlayerDebugBox();
  1961. }
  1962. }
  1963. );
  1964. // UNIX client time before ping
  1965. const beforePing = Date.now();
  1966. this.socket.dispatch("apis.ping", res => {
  1967. if (res.status === "success") {
  1968. // UNIX client time after ping
  1969. const afterPing = Date.now();
  1970. // Average time in MS it took between the server responding and the client receiving
  1971. const connectionLatency =
  1972. (afterPing - beforePing) / 2;
  1973. console.log(
  1974. connectionLatency,
  1975. beforePing - afterPing
  1976. );
  1977. // UNIX server time
  1978. const serverDate = res.data.date;
  1979. // Difference between the server UNIX time and the client UNIX time after ping, with the connectionLatency added to the server UNIX time
  1980. const difference =
  1981. serverDate + connectionLatency - afterPing;
  1982. console.log("Difference: ", difference);
  1983. if (difference > 3000 || difference < -3000) {
  1984. console.log(
  1985. "System time difference is bigger than 3 seconds."
  1986. );
  1987. }
  1988. this.systemDifference = difference;
  1989. }
  1990. });
  1991. } else {
  1992. this.loading = false;
  1993. this.exists = false;
  1994. }
  1995. }
  1996. );
  1997. },
  1998. favoriteStation() {
  1999. this.socket.dispatch(
  2000. "stations.favoriteStation",
  2001. this.station._id,
  2002. res => {
  2003. if (res.status === "success") {
  2004. new Toast("Successfully favorited station.");
  2005. } else new Toast(res.message);
  2006. }
  2007. );
  2008. },
  2009. unfavoriteStation() {
  2010. this.socket.dispatch(
  2011. "stations.unfavoriteStation",
  2012. this.station._id,
  2013. res => {
  2014. if (res.status === "success") {
  2015. new Toast("Successfully unfavorited station.");
  2016. } else new Toast(res.message);
  2017. }
  2018. );
  2019. },
  2020. sendActivityWatchVideoData() {
  2021. if (!this.stationPaused && !this.localPaused && !this.noSong) {
  2022. if (this.activityWatchVideoLastStatus !== "playing") {
  2023. this.activityWatchVideoLastStatus = "playing";
  2024. this.activityWatchVideoLastStartDuration =
  2025. this.currentSong.skipDuration + this.getTimeElapsed();
  2026. }
  2027. if (
  2028. this.activityWatchVideoLastYouTubeId !==
  2029. this.currentSong.youtubeId
  2030. ) {
  2031. this.activityWatchVideoLastYouTubeId =
  2032. this.currentSong.youtubeId;
  2033. this.activityWatchVideoLastStartDuration =
  2034. this.currentSong.skipDuration + this.getTimeElapsed();
  2035. }
  2036. const videoData = {
  2037. title: this.currentSong ? this.currentSong.title : null,
  2038. artists:
  2039. this.currentSong && this.currentSong.artists
  2040. ? this.currentSong.artists.join(", ")
  2041. : null,
  2042. youtubeId: this.currentSong.youtubeId,
  2043. muted: this.muted,
  2044. volume: this.volumeSliderValue / 100,
  2045. startedDuration:
  2046. this.activityWatchVideoLastStartDuration <= 0
  2047. ? 0
  2048. : Math.floor(
  2049. this.activityWatchVideoLastStartDuration /
  2050. 1000
  2051. ),
  2052. source: `station#${this.station.name}`,
  2053. hostname: window.location.hostname
  2054. };
  2055. aw.sendVideoData(videoData);
  2056. } else {
  2057. this.activityWatchVideoLastStatus = "not_playing";
  2058. }
  2059. },
  2060. ...mapActions("modalVisibility", ["openModal"]),
  2061. ...mapActions("station", [
  2062. "joinStation",
  2063. "leaveStation",
  2064. "updateUserCount",
  2065. "updateUsers",
  2066. "updateCurrentSong",
  2067. "updateNextSong",
  2068. "updateSongsList",
  2069. "repositionSongInList",
  2070. "updateStationPaused",
  2071. "updateLocalPaused",
  2072. "updateNoSong",
  2073. "updateIfStationIsFavorited",
  2074. "setIncludedPlaylists",
  2075. "setExcludedPlaylists",
  2076. "updateCurrentSongRatings",
  2077. "updateOwnCurrentSongRatings",
  2078. "updateCurrentSongSkipVotes"
  2079. ]),
  2080. ...mapActions("modals/editSong", ["stopVideo"])
  2081. }
  2082. };
  2083. </script>
  2084. <style lang="scss">
  2085. #stationPlayer {
  2086. position: absolute;
  2087. top: 0;
  2088. left: 0;
  2089. width: 100%;
  2090. height: 100%;
  2091. }
  2092. #currently-playing-container,
  2093. #next-up-container {
  2094. .song-item {
  2095. .song-info {
  2096. width: calc(100% - 80px);
  2097. }
  2098. .thumbnail {
  2099. min-width: 130px;
  2100. width: 130px;
  2101. height: 130px;
  2102. }
  2103. }
  2104. }
  2105. #player-debug-box {
  2106. .box-body {
  2107. // flex-direction: column;
  2108. flex-flow: column;
  2109. span {
  2110. flex: 1;
  2111. display: block;
  2112. }
  2113. b {
  2114. color: var(--black);
  2115. }
  2116. }
  2117. }
  2118. </style>
  2119. <style lang="scss" scoped>
  2120. #page-loader-container {
  2121. height: inherit;
  2122. #page-loader-content {
  2123. height: inherit;
  2124. position: absolute;
  2125. max-width: 100%;
  2126. width: 1800px;
  2127. transform: translateX(-50%);
  2128. left: 50%;
  2129. }
  2130. #page-loader-layout {
  2131. height: inherit;
  2132. width: 100%;
  2133. }
  2134. }
  2135. #mobile-progress-animation {
  2136. width: 50px;
  2137. animation: rotate 0.8s infinite linear;
  2138. border: 8px solid var(--primary-color);
  2139. border-right-color: transparent;
  2140. border-radius: 50%;
  2141. height: 50px;
  2142. position: absolute;
  2143. top: 50%;
  2144. left: 50%;
  2145. display: none;
  2146. }
  2147. @keyframes rotate {
  2148. 0% {
  2149. transform: rotate(0deg);
  2150. }
  2151. 100% {
  2152. transform: rotate(360deg);
  2153. }
  2154. }
  2155. .nav,
  2156. .button.is-primary {
  2157. background-color: var(--primary-color) !important;
  2158. }
  2159. .button.is-primary:hover,
  2160. .button.is-primary:focus {
  2161. filter: brightness(90%);
  2162. }
  2163. .night-mode {
  2164. #currently-playing-container,
  2165. #next-up-container,
  2166. #about-station-container,
  2167. #control-bar-container,
  2168. .player-container {
  2169. background-color: var(--dark-grey-3) !important;
  2170. }
  2171. #video-container,
  2172. #control-bar-container,
  2173. .quadrant:not(#sidebar-container),
  2174. .player-container {
  2175. border: 0 !important;
  2176. }
  2177. #seeker-bar-container {
  2178. background-color: var(--dark-grey-3) !important;
  2179. }
  2180. #dropdown-toggle {
  2181. background-color: var(--dark-grey-2) !important;
  2182. border: 0;
  2183. i {
  2184. color: var(--white);
  2185. }
  2186. }
  2187. }
  2188. #station-outer-container {
  2189. margin: 0 auto;
  2190. padding: 20px 40px;
  2191. min-height: calc(100vh - 64px);
  2192. width: 100%;
  2193. max-width: 1800px;
  2194. display: flex;
  2195. #station-inner-container {
  2196. width: 100%;
  2197. // height: fit-content;
  2198. min-height: calc(100vh - 428px);
  2199. display: flex;
  2200. flex-direction: row;
  2201. flex-wrap: wrap;
  2202. .row {
  2203. display: flex;
  2204. flex-direction: row;
  2205. max-width: 100%;
  2206. }
  2207. .column {
  2208. display: flex;
  2209. flex-direction: column;
  2210. }
  2211. .quadrant {
  2212. border-radius: 5px;
  2213. margin: 10px;
  2214. }
  2215. .quadrant:not(#sidebar-container) {
  2216. background-color: var(--white);
  2217. border: 1px solid var(--light-grey-3);
  2218. }
  2219. #station-left-column,
  2220. #station-right-column {
  2221. padding: 0;
  2222. }
  2223. #about-station-container {
  2224. padding: 20px;
  2225. display: flex;
  2226. flex-direction: column;
  2227. flex-grow: unset;
  2228. #station-info {
  2229. #station-name {
  2230. flex-direction: row !important;
  2231. h1 {
  2232. margin: 0;
  2233. font-size: 36px;
  2234. line-height: 0.8;
  2235. }
  2236. i {
  2237. margin-left: 10px;
  2238. font-size: 30px;
  2239. color: var(--yellow);
  2240. &.stationMode {
  2241. padding-left: 10px;
  2242. margin-left: auto;
  2243. color: var(--primary-color);
  2244. }
  2245. }
  2246. }
  2247. p {
  2248. max-width: 700px;
  2249. margin-bottom: 10px;
  2250. }
  2251. }
  2252. #admin-buttons {
  2253. display: flex;
  2254. .button {
  2255. margin: 3px;
  2256. }
  2257. }
  2258. }
  2259. #current-next-row {
  2260. display: flex;
  2261. flex-direction: row;
  2262. // max-width: calc(100vw - 40px);
  2263. #currently-playing-container,
  2264. #next-up-container {
  2265. overflow: hidden;
  2266. flex-basis: 50%;
  2267. .song-item {
  2268. border: unset;
  2269. }
  2270. .nothing-here-text {
  2271. height: 100%;
  2272. }
  2273. }
  2274. > div:only-child {
  2275. flex: 1 !important;
  2276. flex-basis: 100% !important;
  2277. }
  2278. }
  2279. .player-container {
  2280. height: inherit;
  2281. background-color: var(--white);
  2282. display: flex;
  2283. flex-direction: column;
  2284. border: 1px solid var(--light-grey-3);
  2285. border-radius: 5px;
  2286. overflow: hidden;
  2287. &.nothing-here-text {
  2288. margin: 10px;
  2289. flex: 1;
  2290. min-height: 487px;
  2291. }
  2292. #video-container {
  2293. position: relative;
  2294. padding-bottom: 56.25%; /* proportion value to aspect ratio 16:9 (9 / 16 = 0.5625 or 56.25%) */
  2295. height: 0;
  2296. overflow: hidden;
  2297. .player-cannot-autoplay {
  2298. position: relative;
  2299. width: 100%;
  2300. height: 100%;
  2301. bottom: calc(100% + 5px);
  2302. background: var(--primary-color);
  2303. display: flex;
  2304. align-items: center;
  2305. justify-content: center;
  2306. p {
  2307. color: var(--white);
  2308. font-size: 26px;
  2309. text-align: center;
  2310. }
  2311. }
  2312. }
  2313. #seeker-bar-container {
  2314. background-color: var(--white);
  2315. position: relative;
  2316. height: 7px;
  2317. display: block;
  2318. width: 100%;
  2319. #seeker-bar {
  2320. background-color: var(--primary-color);
  2321. top: 0;
  2322. left: 0;
  2323. bottom: 0;
  2324. position: absolute;
  2325. }
  2326. }
  2327. #control-bar-container {
  2328. display: flex;
  2329. justify-content: space-around;
  2330. padding: 10px 0;
  2331. width: 100%;
  2332. background: var(--white);
  2333. flex-direction: column;
  2334. flex-flow: wrap;
  2335. .button:not(#dropdown-toggle) {
  2336. width: 75px;
  2337. }
  2338. #left-buttons,
  2339. #right-buttons {
  2340. margin: 3px;
  2341. }
  2342. #left-buttons {
  2343. display: flex;
  2344. .button:not(:first-of-type) {
  2345. margin-left: 5px;
  2346. }
  2347. .disabled {
  2348. filter: grayscale(0.4);
  2349. }
  2350. }
  2351. #duration {
  2352. margin: 3px;
  2353. display: flex;
  2354. align-items: center;
  2355. p {
  2356. font-size: 22px;
  2357. /** prevents duration width slightly varying and shifting other controls slightly */
  2358. width: 150px;
  2359. text-align: center;
  2360. }
  2361. }
  2362. #volume-control {
  2363. margin: 3px;
  2364. margin-top: 0;
  2365. display: flex;
  2366. align-items: center;
  2367. cursor: pointer;
  2368. .volume-slider {
  2369. width: 100%;
  2370. padding: 0 15px;
  2371. background: transparent;
  2372. min-width: 100px;
  2373. }
  2374. input[type="range"] {
  2375. -webkit-appearance: none;
  2376. margin: 7.3px 0;
  2377. }
  2378. input[type="range"]:focus {
  2379. outline: none;
  2380. }
  2381. input[type="range"]::-webkit-slider-runnable-track {
  2382. width: 100%;
  2383. height: 5.2px;
  2384. cursor: pointer;
  2385. box-shadow: 0;
  2386. background: var(--light-grey-3);
  2387. border-radius: 0;
  2388. border: 0;
  2389. }
  2390. input[type="range"]::-webkit-slider-thumb {
  2391. box-shadow: 0;
  2392. border: 0;
  2393. height: 19px;
  2394. width: 19px;
  2395. border-radius: 15px;
  2396. background: var(--primary-color);
  2397. cursor: pointer;
  2398. -webkit-appearance: none;
  2399. margin-top: -6.5px;
  2400. }
  2401. input[type="range"]::-moz-range-track {
  2402. width: 100%;
  2403. height: 5.2px;
  2404. cursor: pointer;
  2405. box-shadow: 0;
  2406. background: var(--light-grey-3);
  2407. border-radius: 0;
  2408. border: 0;
  2409. }
  2410. input[type="range"]::-moz-range-thumb {
  2411. box-shadow: 0;
  2412. border: 0;
  2413. height: 19px;
  2414. width: 19px;
  2415. border-radius: 15px;
  2416. background: var(--primary-color);
  2417. cursor: pointer;
  2418. -webkit-appearance: none;
  2419. margin-top: -6.5px;
  2420. }
  2421. input[type="range"]::-ms-track {
  2422. width: 100%;
  2423. height: 5.2px;
  2424. cursor: pointer;
  2425. box-shadow: 0;
  2426. background: var(--light-grey-3);
  2427. border-radius: 1.3px;
  2428. }
  2429. input[type="range"]::-ms-fill-lower {
  2430. background: var(--light-grey-3);
  2431. border: 0;
  2432. border-radius: 0;
  2433. box-shadow: 0;
  2434. }
  2435. input[type="range"]::-ms-fill-upper {
  2436. background: var(--light-grey-3);
  2437. border: 0;
  2438. border-radius: 0;
  2439. box-shadow: 0;
  2440. }
  2441. input[type="range"]::-ms-thumb {
  2442. box-shadow: 0;
  2443. border: 0;
  2444. height: 15px;
  2445. width: 15px;
  2446. border-radius: 15px;
  2447. background: var(--primary-color);
  2448. cursor: pointer;
  2449. -webkit-appearance: none;
  2450. margin-top: 1.5px;
  2451. }
  2452. }
  2453. #right-buttons {
  2454. display: flex;
  2455. #dropdown-toggle {
  2456. width: 35px;
  2457. }
  2458. #dislike-song,
  2459. #add-song-to-playlist .button:not(#dropdown-toggle) {
  2460. margin-left: 5px;
  2461. }
  2462. #ratings {
  2463. display: flex;
  2464. &.liked #dislike-song,
  2465. &.disliked #like-song {
  2466. background-color: var(--grey) !important;
  2467. }
  2468. #like-song.disabled,
  2469. #dislike-song.disabled {
  2470. filter: grayscale(0.4);
  2471. }
  2472. }
  2473. #add-song-to-playlist {
  2474. display: flex;
  2475. flex-direction: column-reverse;
  2476. #nav-dropdown {
  2477. position: absolute;
  2478. margin-left: 4px;
  2479. margin-bottom: 36px;
  2480. .nav-dropdown-items {
  2481. position: relative;
  2482. right: calc(100% - 110px);
  2483. }
  2484. }
  2485. .control {
  2486. width: fit-content;
  2487. margin-bottom: 0 !important;
  2488. button.disabled {
  2489. filter: grayscale(0.4);
  2490. border-radius: 3px;
  2491. &::after {
  2492. margin-right: 100%;
  2493. }
  2494. }
  2495. }
  2496. }
  2497. }
  2498. }
  2499. }
  2500. #sidebar-container {
  2501. border-top: 0;
  2502. position: relative;
  2503. height: inherit;
  2504. flex-grow: 1;
  2505. min-height: 350px;
  2506. }
  2507. }
  2508. }
  2509. .footer {
  2510. margin-top: 30px;
  2511. }
  2512. .nyan {
  2513. background: linear-gradient(
  2514. 90deg,
  2515. magenta 0%,
  2516. red 15%,
  2517. orange 30%,
  2518. yellow 45%,
  2519. lime 60%,
  2520. cyan 75%,
  2521. blue 90%,
  2522. magenta 100%
  2523. );
  2524. background-size: 200%;
  2525. animation: nyanMoving 4s linear infinite;
  2526. }
  2527. @keyframes nyanMoving {
  2528. 0% {
  2529. background-position: 0% 0%;
  2530. }
  2531. 100% {
  2532. background-position: -200% 0%;
  2533. }
  2534. }
  2535. .bg-bubbles {
  2536. top: 0;
  2537. left: 0;
  2538. width: 100%;
  2539. height: 100%;
  2540. position: absolute;
  2541. z-index: -1;
  2542. margin: 0px;
  2543. pointer-events: none;
  2544. }
  2545. .bg-bubbles li {
  2546. position: absolute;
  2547. list-style: none;
  2548. display: block;
  2549. width: 40px;
  2550. height: 40px;
  2551. border-radius: 100px;
  2552. // background-color: rgba(255, 255, 255, 0.15);
  2553. background-color: var(--primary-color);
  2554. opacity: 0.15;
  2555. bottom: 0px;
  2556. -webkit-animation: square 25s infinite;
  2557. animation: square 25s infinite;
  2558. -webkit-transition-timing-function: linear;
  2559. transition-timing-function: linear;
  2560. }
  2561. .bg-bubbles li:nth-child(1) {
  2562. left: 10%;
  2563. }
  2564. .bg-bubbles li:nth-child(2) {
  2565. left: 20%;
  2566. width: 80px;
  2567. height: 80px;
  2568. -webkit-animation-delay: 2s;
  2569. animation-delay: 2s;
  2570. -webkit-animation-duration: 17s;
  2571. animation-duration: 17s;
  2572. }
  2573. .bg-bubbles li:nth-child(3) {
  2574. left: 25%;
  2575. -webkit-animation-delay: 4s;
  2576. animation-delay: 4s;
  2577. }
  2578. .bg-bubbles li:nth-child(4) {
  2579. left: 40%;
  2580. width: 60px;
  2581. height: 60px;
  2582. -webkit-animation-duration: 22s;
  2583. animation-duration: 22s;
  2584. // background-color: rgba(255, 255, 255, 0.25);
  2585. background-color: var(--primary-color);
  2586. opacity: 0.25;
  2587. }
  2588. .bg-bubbles li:nth-child(5) {
  2589. left: 70%;
  2590. }
  2591. .bg-bubbles li:nth-child(6) {
  2592. left: 80%;
  2593. width: 120px;
  2594. height: 120px;
  2595. -webkit-animation-delay: 3s;
  2596. animation-delay: 3s;
  2597. // background-color: rgba(255, 255, 255, 0.2);
  2598. background-color: var(--primary-color);
  2599. opacity: 0.2;
  2600. }
  2601. .bg-bubbles li:nth-child(7) {
  2602. left: 32%;
  2603. width: 160px;
  2604. height: 160px;
  2605. -webkit-animation-delay: 7s;
  2606. animation-delay: 7s;
  2607. }
  2608. .bg-bubbles li:nth-child(8) {
  2609. left: 55%;
  2610. width: 20px;
  2611. height: 20px;
  2612. -webkit-animation-delay: 15s;
  2613. animation-delay: 15s;
  2614. -webkit-animation-duration: 40s;
  2615. animation-duration: 40s;
  2616. }
  2617. .bg-bubbles li:nth-child(9) {
  2618. left: 25%;
  2619. width: 10px;
  2620. height: 10px;
  2621. -webkit-animation-delay: 2s;
  2622. animation-delay: 2s;
  2623. -webkit-animation-duration: 40s;
  2624. animation-duration: 40s;
  2625. // background-color: rgba(255, 255, 255, 0.3);
  2626. background-color: var(--primary-color);
  2627. opacity: 0.3;
  2628. }
  2629. .bg-bubbles li:nth-child(10) {
  2630. left: 80%;
  2631. width: 160px;
  2632. height: 160px;
  2633. -webkit-animation-delay: 11s;
  2634. animation-delay: 11s;
  2635. }
  2636. /* Tablet view fix */
  2637. @media (max-width: 768px) {
  2638. .bg-bubbles li:nth-child(10) {
  2639. display: none;
  2640. }
  2641. }
  2642. @-webkit-keyframes square {
  2643. 0% {
  2644. -webkit-transform: translateY(0);
  2645. transform: translateY(0);
  2646. }
  2647. 100% {
  2648. -webkit-transform: translateY(-700px) rotate(600deg);
  2649. transform: translateY(-700px) rotate(600deg);
  2650. }
  2651. }
  2652. @keyframes square {
  2653. 0% {
  2654. -webkit-transform: translateY(0);
  2655. transform: translateY(0);
  2656. }
  2657. 100% {
  2658. -webkit-transform: translateY(-700px) rotate(600deg);
  2659. transform: translateY(-700px) rotate(600deg);
  2660. }
  2661. }
  2662. /deep/ .nothing-here-text {
  2663. display: flex;
  2664. align-items: center;
  2665. justify-content: center;
  2666. }
  2667. @media (min-width: 1500px) {
  2668. #station-left-column {
  2669. max-width: 650px;
  2670. }
  2671. #station-right-column {
  2672. max-width: calc(100% - 650px);
  2673. }
  2674. }
  2675. @media (max-width: 1700px) {
  2676. #current-next-row {
  2677. flex-direction: column !important;
  2678. > div {
  2679. flex: 1 !important;
  2680. }
  2681. }
  2682. }
  2683. @media (max-width: 1500px) {
  2684. #mobile-progress-animation {
  2685. display: block;
  2686. }
  2687. #page-loader-container {
  2688. display: none;
  2689. }
  2690. #station-outer-container {
  2691. max-width: 1500px;
  2692. #station-inner-container {
  2693. flex-direction: row;
  2694. #station-left-column {
  2695. #about-station-container #admin-buttons {
  2696. flex-wrap: wrap;
  2697. }
  2698. #sidebar-container {
  2699. min-height: 350px;
  2700. }
  2701. }
  2702. #station-right-column {
  2703. #current-next-row {
  2704. flex-direction: column;
  2705. }
  2706. #control-bar-container {
  2707. #duration,
  2708. #volume-control,
  2709. #right-buttons,
  2710. #left-buttons {
  2711. margin-bottom: 5px;
  2712. justify-content: center;
  2713. }
  2714. #duration {
  2715. order: 1;
  2716. }
  2717. #volume-control {
  2718. order: 2;
  2719. max-width: 400px;
  2720. }
  2721. #right-buttons {
  2722. order: 3;
  2723. flex-wrap: wrap;
  2724. #ratings {
  2725. flex-wrap: wrap;
  2726. }
  2727. }
  2728. #left-buttons {
  2729. order: 4;
  2730. flex-wrap: wrap;
  2731. }
  2732. }
  2733. }
  2734. }
  2735. }
  2736. }
  2737. @media (max-width: 1200px) {
  2738. #station-outer-container {
  2739. max-width: 900px;
  2740. padding: 0;
  2741. #station-inner-container {
  2742. flex-direction: column-reverse;
  2743. flex-wrap: nowrap;
  2744. }
  2745. }
  2746. }
  2747. @media (max-width: 990px) {
  2748. #station-outer-container {
  2749. min-height: calc(
  2750. 100vh - 256px
  2751. ); // Height of nav (64px) + height of footer (190px)
  2752. }
  2753. }
  2754. </style>