index.vue 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297
  1. <template>
  2. <div>
  3. <modal title="Edit Song" class="song-modal">
  4. <template #body>
  5. <div class="left-section">
  6. <div class="top-section">
  7. <div class="player-section">
  8. <div id="video-container">
  9. <div
  10. id="editSongPlayer"
  11. style="
  12. width: 100%;
  13. height: 100%;
  14. min-height: 200px;
  15. "
  16. />
  17. </div>
  18. <div v-show="youtubeError" class="player-error">
  19. <h2>{{ youtubeErrorMessage }}</h2>
  20. </div>
  21. <canvas
  22. ref="durationCanvas"
  23. id="durationCanvas"
  24. v-show="!youtubeError"
  25. height="20"
  26. width="530"
  27. />
  28. <div class="player-footer">
  29. <div class="player-footer-left">
  30. <button
  31. class="button is-primary"
  32. @click="play()"
  33. @keyup.enter="play()"
  34. v-if="video.paused"
  35. content="Unpause Playback"
  36. v-tippy
  37. >
  38. <i class="material-icons">play_arrow</i>
  39. </button>
  40. <button
  41. class="button is-primary"
  42. @click="settings('pause')"
  43. @keyup.enter="settings('pause')"
  44. v-else
  45. content="Pause Playback"
  46. v-tippy
  47. >
  48. <i class="material-icons">pause</i>
  49. </button>
  50. <button
  51. class="button is-danger"
  52. @click="settings('stop')"
  53. @keyup.enter="settings('stop')"
  54. content="Stop Playback"
  55. v-tippy
  56. >
  57. <i class="material-icons">stop</i>
  58. </button>
  59. <button
  60. class="button is-success"
  61. @click="settings('skipToLast10Secs')"
  62. @keyup.enter="
  63. settings('skipToLast10Secs')
  64. "
  65. content="Skip to last 10 secs"
  66. v-tippy
  67. >
  68. <i class="material-icons"
  69. >fast_forward</i
  70. >
  71. </button>
  72. </div>
  73. <div class="player-footer-center">
  74. <img src="/assets/social/youtube.svg" />
  75. <span>
  76. <span>
  77. {{ youtubeVideoCurrentTime }}
  78. </span>
  79. /
  80. <span>
  81. {{ youtubeVideoDuration }}
  82. {{ youtubeVideoNote }}
  83. </span>
  84. </span>
  85. </div>
  86. <div class="player-footer-right">
  87. <p id="volume-control">
  88. <i
  89. v-if="muted"
  90. class="material-icons"
  91. @click="toggleMute()"
  92. content="Unmute"
  93. v-tippy
  94. >volume_mute</i
  95. >
  96. <i
  97. v-else
  98. class="material-icons"
  99. @click="toggleMute()"
  100. content="Mute"
  101. v-tippy
  102. >volume_down</i
  103. >
  104. <input
  105. v-model="volumeSliderValue"
  106. type="range"
  107. min="0"
  108. max="10000"
  109. class="volume-slider active"
  110. @change="changeVolume()"
  111. @input="changeVolume()"
  112. />
  113. <i
  114. class="material-icons"
  115. @click="increaseVolume()"
  116. content="Increase Volume"
  117. v-tippy
  118. >volume_up</i
  119. >
  120. </p>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. <div class="edit-section" v-if="songDataLoaded">
  126. <div class="control is-grouped">
  127. <div class="title-container">
  128. <label class="label">Title</label>
  129. <p class="control has-addons">
  130. <input
  131. class="input"
  132. type="text"
  133. ref="title-input"
  134. v-model="song.title"
  135. placeholder="Enter song title..."
  136. @keyup.shift.enter="
  137. getAlbumData('title')
  138. "
  139. />
  140. <button
  141. class="button album-get-button"
  142. @click="getAlbumData('title')"
  143. >
  144. <i
  145. class="material-icons"
  146. v-tippy
  147. content="Fill from Discogs"
  148. >album</i
  149. >
  150. </button>
  151. </p>
  152. </div>
  153. <div class="duration-container">
  154. <label class="label">Duration</label>
  155. <p class="control has-addons">
  156. <input
  157. class="input"
  158. type="text"
  159. placeholder="Enter song duration..."
  160. v-model.number="song.duration"
  161. @keyup.shift.enter="fillDuration()"
  162. />
  163. <button
  164. class="button duration-fill-button"
  165. @click="fillDuration()"
  166. >
  167. <i
  168. class="material-icons"
  169. v-tippy
  170. content="Sync duration with YouTube"
  171. >sync</i
  172. >
  173. </button>
  174. </p>
  175. </div>
  176. <div class="skip-duration-container">
  177. <label class="label">Skip duration</label>
  178. <p class="control">
  179. <input
  180. class="input"
  181. type="text"
  182. placeholder="Enter skip duration..."
  183. v-model.number="song.skipDuration"
  184. />
  185. </p>
  186. </div>
  187. </div>
  188. <div class="control is-grouped album-art-container">
  189. <label class="label">Album art</label>
  190. <div>
  191. <img
  192. class="thumbnail-preview"
  193. :src="song.thumbnail"
  194. onerror="this.src='/assets/notes-transparent.png'"
  195. ref="thumbnailElement"
  196. v-if="songDataLoaded"
  197. />
  198. <p class="control has-addons">
  199. <input
  200. class="input"
  201. type="text"
  202. v-model="song.thumbnail"
  203. placeholder="Enter link to album art..."
  204. @keyup.shift.enter="
  205. getAlbumData('albumArt')
  206. "
  207. />
  208. <button
  209. class="button album-get-button"
  210. @click="getAlbumData('albumArt')"
  211. >
  212. <i
  213. class="material-icons"
  214. v-tippy
  215. content="Fill from Discogs"
  216. >album</i
  217. >
  218. </button>
  219. </p>
  220. </div>
  221. </div>
  222. <div class="control is-grouped">
  223. <div class="artists-container">
  224. <label class="label">Artists</label>
  225. <p class="control has-addons">
  226. <input
  227. class="input"
  228. type="text"
  229. ref="new-artist"
  230. v-model="artistInputValue"
  231. placeholder="Add artist..."
  232. @blur="blurArtistInput()"
  233. @focus="focusArtistInput()"
  234. @keydown="keydownArtistInput()"
  235. @keyup.exact.enter="addTag('artists')"
  236. @keyup.shift.enter="
  237. getAlbumData('artists')
  238. "
  239. />
  240. <button
  241. class="button album-get-button"
  242. @click="getAlbumData('artists')"
  243. >
  244. <i
  245. class="material-icons"
  246. v-tippy
  247. content="Fill from Discogs"
  248. >album</i
  249. >
  250. </button>
  251. <button
  252. class="button is-info add-button"
  253. @click="addTag('artists')"
  254. >
  255. <i class="material-icons">add</i>
  256. </button>
  257. </p>
  258. <div
  259. class="autosuggest-container"
  260. v-if="
  261. (artistInputFocussed ||
  262. artistAutosuggestContainerFocussed) &&
  263. artistAutosuggestItems.length > 0
  264. "
  265. @mouseover="focusArtistContainer()"
  266. @mouseleave="blurArtistContainer()"
  267. >
  268. <span
  269. class="autosuggest-item"
  270. tabindex="0"
  271. @click="addTag('artists', item)"
  272. v-for="item in artistAutosuggestItems"
  273. :key="item"
  274. >{{ item }}</span
  275. >
  276. </div>
  277. <div class="list-container">
  278. <div
  279. class="list-item"
  280. v-for="artist in song.artists"
  281. :key="artist"
  282. >
  283. <div
  284. class="list-item-circle"
  285. @click="
  286. removeTag('artists', artist)
  287. "
  288. >
  289. <i class="material-icons">close</i>
  290. </div>
  291. <p>{{ artist }}</p>
  292. </div>
  293. </div>
  294. </div>
  295. <div class="genres-container">
  296. <label class="label">
  297. <span>Genres</span>
  298. <i
  299. class="material-icons"
  300. @click="toggleGenreHelper"
  301. @dblclick="resetGenreHelper"
  302. v-tippy
  303. content="View list of genres"
  304. >info</i
  305. >
  306. </label>
  307. <p class="control has-addons">
  308. <input
  309. class="input"
  310. type="text"
  311. ref="new-genre"
  312. v-model="genreInputValue"
  313. placeholder="Add genre..."
  314. @blur="blurGenreInput()"
  315. @focus="focusGenreInput()"
  316. @keydown="keydownGenreInput()"
  317. @keyup.exact.enter="addTag('genres')"
  318. @keyup.shift.enter="
  319. getAlbumData('genres')
  320. "
  321. />
  322. <button
  323. class="button album-get-button"
  324. @click="getAlbumData('genres')"
  325. >
  326. <i
  327. class="material-icons"
  328. v-tippy
  329. content="Fill from Discogs"
  330. >album</i
  331. >
  332. </button>
  333. <button
  334. class="button is-info add-button"
  335. @click="addTag('genres')"
  336. >
  337. <i class="material-icons">add</i>
  338. </button>
  339. </p>
  340. <div
  341. class="autosuggest-container"
  342. v-if="
  343. (genreInputFocussed ||
  344. genreAutosuggestContainerFocussed) &&
  345. genreAutosuggestItems.length > 0
  346. "
  347. @mouseover="focusGenreContainer()"
  348. @mouseleave="blurGenreContainer()"
  349. >
  350. <span
  351. class="autosuggest-item"
  352. @click="addTag('genres', item)"
  353. v-for="item in genreAutosuggestItems"
  354. :key="item"
  355. >{{ item }}</span
  356. >
  357. </div>
  358. <div class="list-container">
  359. <div
  360. class="list-item"
  361. v-for="genre in song.genres"
  362. :key="genre"
  363. >
  364. <div
  365. class="list-item-circle"
  366. @click="removeTag('genres', genre)"
  367. >
  368. <i class="material-icons">close</i>
  369. </div>
  370. <p>{{ genre }}</p>
  371. </div>
  372. </div>
  373. </div>
  374. <div class="youtube-id-container">
  375. <label class="label">YouTube ID</label>
  376. <p class="control">
  377. <input
  378. class="input"
  379. type="text"
  380. placeholder="Enter YouTube ID..."
  381. v-model="song.youtubeId"
  382. />
  383. </p>
  384. </div>
  385. </div>
  386. </div>
  387. </div>
  388. <div class="right-section" v-if="songDataLoaded">
  389. <div id="tabs-container">
  390. <div id="tab-selection">
  391. <button
  392. class="button is-default"
  393. :class="{ selected: tab === 'discogs' }"
  394. ref="discogs-tab"
  395. @click="showTab('discogs')"
  396. >
  397. Discogs
  398. </button>
  399. <button
  400. class="button is-default"
  401. :class="{ selected: tab === 'reports' }"
  402. ref="reports-tab"
  403. @click="showTab('reports')"
  404. >
  405. Reports ({{ reports.length }})
  406. </button>
  407. <button
  408. class="button is-default"
  409. :class="{ selected: tab === 'youtube' }"
  410. ref="youtube-tab"
  411. @click="showTab('youtube')"
  412. >
  413. YouTube
  414. </button>
  415. </div>
  416. <discogs class="tab" v-show="tab === 'discogs'" />
  417. <reports class="tab" v-show="tab === 'reports'" />
  418. <youtube class="tab" v-show="tab === 'youtube'" />
  419. </div>
  420. </div>
  421. </template>
  422. <template #footer>
  423. <div>
  424. <save-button
  425. ref="saveButton"
  426. @clicked="save(song, false, false)"
  427. />
  428. <save-button
  429. ref="saveAndCloseButton"
  430. default-message="Save and close"
  431. @clicked="save(song, false, true)"
  432. />
  433. <save-button
  434. ref="saveVerifyAndCloseButton"
  435. default-message="Save, verify and close"
  436. @click="save(song, true, true)"
  437. />
  438. <button
  439. class="button is-danger"
  440. @click="stopEditingSongs()"
  441. v-if="modals.importAlbum && editingSongs"
  442. >
  443. Stop editing songs
  444. </button>
  445. <div class="right">
  446. <button
  447. v-if="song.status !== 'verified'"
  448. class="button is-success"
  449. @click="verify(song._id)"
  450. content="Verify Song"
  451. v-tippy
  452. >
  453. <i class="material-icons">check_circle</i>
  454. </button>
  455. <confirm
  456. v-if="song.status === 'verified'"
  457. placement="left"
  458. @confirm="unverify(song._id)"
  459. >
  460. <button
  461. class="button is-danger"
  462. content="Unverify Song"
  463. v-tippy
  464. >
  465. <i class="material-icons">cancel</i>
  466. </button>
  467. </confirm>
  468. <confirm
  469. v-if="song.status !== 'hidden'"
  470. placement="left"
  471. @confirm="hide(song._id)"
  472. >
  473. <button
  474. class="button is-danger"
  475. content="Hide Song"
  476. v-tippy
  477. >
  478. <i class="material-icons">visibility_off</i>
  479. </button>
  480. </confirm>
  481. <button
  482. v-if="song.status === 'hidden'"
  483. class="button is-success"
  484. @click="unhide(song._id)"
  485. content="Unhide Song"
  486. v-tippy
  487. >
  488. <i class="material-icons">visibility</i>
  489. </button>
  490. <!-- <confirm placement="left" @confirm="remove(song._id)">
  491. <button
  492. class="button is-danger"
  493. content="Remove Song"
  494. v-tippy
  495. >
  496. <i class="material-icons">delete</i>
  497. </button>
  498. </confirm> -->
  499. </div>
  500. </div>
  501. </template>
  502. </modal>
  503. <floating-box id="genreHelper" ref="genreHelper" :column="false">
  504. <template #body>
  505. <span>Blues</span><span>Country</span><span>Disco</span
  506. ><span>Funk</span><span>Hip-Hop</span><span>Jazz</span
  507. ><span>Metal</span><span>Oldies</span><span>Other</span
  508. ><span>Pop</span><span>Rap</span><span>Reggae</span
  509. ><span>Rock</span><span>Techno</span><span>Trance</span
  510. ><span>Classical</span><span>Instrumental</span
  511. ><span>House</span><span>Electronic</span
  512. ><span>Christian Rap</span><span>Lo-Fi</span><span>Musical</span
  513. ><span>Rock 'n' Roll</span><span>Opera</span
  514. ><span>Drum & Bass</span><span>Club-House</span
  515. ><span>Indie</span><span>Heavy Metal</span
  516. ><span>Christian rock</span><span>Dubstep</span>
  517. </template>
  518. </floating-box>
  519. </div>
  520. </template>
  521. <script>
  522. import { mapState, mapGetters, mapActions } from "vuex";
  523. import Toast from "toasters";
  524. import aw from "@/aw";
  525. import ws from "@/ws";
  526. import validation from "@/validation";
  527. import keyboardShortcuts from "@/keyboardShortcuts";
  528. import Confirm from "@/components/Confirm.vue";
  529. import Modal from "../../Modal.vue";
  530. import FloatingBox from "../../FloatingBox.vue";
  531. import SaveButton from "../../SaveButton.vue";
  532. import Discogs from "./Tabs/Discogs.vue";
  533. import Reports from "./Tabs/Reports.vue";
  534. import Youtube from "./Tabs/Youtube.vue";
  535. export default {
  536. components: {
  537. Modal,
  538. FloatingBox,
  539. SaveButton,
  540. Confirm,
  541. Discogs,
  542. Reports,
  543. Youtube
  544. },
  545. props: {
  546. youtubeId: { type: String, default: null },
  547. songId: { type: String, default: null },
  548. discogsAlbum: { type: Object, default: null },
  549. // songType: { type: String, default: null },
  550. sector: { type: String, default: "admin" }
  551. },
  552. data() {
  553. return {
  554. songDataLoaded: false,
  555. youtubeError: false,
  556. youtubeErrorMessage: "",
  557. focusedElementBefore: null,
  558. youtubeVideoDuration: "0.000",
  559. youtubeVideoCurrentTime: 0,
  560. youtubeVideoNote: "",
  561. useHTTPS: false,
  562. muted: false,
  563. volumeSliderValue: 0,
  564. skipToLast10SecsPressed: false,
  565. artistInputValue: "",
  566. genreInputValue: "",
  567. artistInputFocussed: false,
  568. genreInputFocussed: false,
  569. genreAutosuggestContainerFocussed: false,
  570. artistAutosuggestContainerFocussed: false,
  571. keydownArtistInputTimeout: 0,
  572. keydownGenreInputTimeout: 0,
  573. artistAutosuggestItems: [],
  574. genreAutosuggestItems: [],
  575. activityWatchVideoDataInterval: null,
  576. activityWatchVideoLastStatus: "",
  577. activityWatchVideoLastStartDuration: "",
  578. genres: [
  579. "Blues",
  580. "Country",
  581. "Disco",
  582. "Funk",
  583. "Hip-Hop",
  584. "Jazz",
  585. "Metal",
  586. "Oldies",
  587. "Other",
  588. "Pop",
  589. "Rap",
  590. "Reggae",
  591. "Rock",
  592. "Techno",
  593. "Trance",
  594. "Classical",
  595. "Instrumental",
  596. "House",
  597. "Electronic",
  598. "Christian Rap",
  599. "Lo-Fi",
  600. "Musical",
  601. "Rock 'n' Roll",
  602. "Opera",
  603. "Drum & Bass",
  604. "Club-House",
  605. "Indie",
  606. "Heavy Metal",
  607. "Christian rock",
  608. "Dubstep"
  609. ]
  610. };
  611. },
  612. computed: {
  613. ...mapState("modals/editSong", {
  614. tab: state => state.tab,
  615. video: state => state.video,
  616. song: state => state.song,
  617. originalSong: state => state.originalSong,
  618. reports: state => state.reports
  619. }),
  620. ...mapState("modals/importAlbum", {
  621. editingSongs: state => state.editingSongs
  622. }),
  623. ...mapState("modalVisibility", {
  624. modals: state => state.modals
  625. }),
  626. ...mapGetters({
  627. socket: "websockets/getSocket"
  628. })
  629. },
  630. watch: {
  631. /* eslint-disable */
  632. "song.duration": function () {
  633. this.drawCanvas();
  634. },
  635. "song.skipDuration": function () {
  636. this.drawCanvas();
  637. }
  638. /* eslint-enable */
  639. },
  640. async mounted() {
  641. // if (this.modals.editSong = false) this.video.player.stopVideo();
  642. // this.loadVideoById(
  643. // this.song.youtubeId,
  644. // this.song.skipDuration
  645. // );
  646. this.activityWatchVideoDataInterval = setInterval(() => {
  647. this.sendActivityWatchVideoData();
  648. }, 1000);
  649. this.useHTTPS = await lofig.get("cookie.secure");
  650. ws.onConnect(this.init);
  651. let volume = parseFloat(localStorage.getItem("volume"));
  652. volume =
  653. typeof volume === "number" && !Number.isNaN(volume) ? volume : 20;
  654. localStorage.setItem("volume", volume);
  655. this.volumeSliderValue = volume * 100;
  656. this.socket.on(
  657. "event:admin.hiddenSong.created",
  658. res => {
  659. if (res.data.song._id === this.song._id)
  660. this.song.status = res.data.song.status;
  661. },
  662. { modal: "editSong" }
  663. );
  664. this.socket.on(
  665. "event:admin.unverifiedSong.created",
  666. res => {
  667. if (res.data.song._id === this.song._id)
  668. this.song.status = res.data.song.status;
  669. },
  670. { modal: "editSong" }
  671. );
  672. this.socket.on(
  673. "event:admin.verifiedSong.created",
  674. res => {
  675. if (res.data.song._id === this.song._id)
  676. this.song.status = res.data.song.status;
  677. },
  678. { modal: "editSong" }
  679. );
  680. keyboardShortcuts.registerShortcut("editSong.pauseResumeVideo", {
  681. keyCode: 101,
  682. preventDefault: true,
  683. handler: () => {
  684. if (this.video.paused) this.play();
  685. else this.settings("pause");
  686. }
  687. });
  688. keyboardShortcuts.registerShortcut("editSong.stopVideo", {
  689. keyCode: 101,
  690. ctrl: true,
  691. preventDefault: true,
  692. handler: () => {
  693. this.settings("stop");
  694. }
  695. });
  696. keyboardShortcuts.registerShortcut("editSong.skipToLast10Secs", {
  697. keyCode: 102,
  698. preventDefault: true,
  699. handler: () => {
  700. this.settings("skipToLast10Secs");
  701. }
  702. });
  703. keyboardShortcuts.registerShortcut("editSong.lowerVolumeLarge", {
  704. keyCode: 98,
  705. preventDefault: true,
  706. handler: () => {
  707. this.volumeSliderValue = Math.max(
  708. 0,
  709. this.volumeSliderValue - 1000
  710. );
  711. this.changeVolume();
  712. }
  713. });
  714. keyboardShortcuts.registerShortcut("editSong.lowerVolumeSmall", {
  715. keyCode: 98,
  716. ctrl: true,
  717. preventDefault: true,
  718. handler: () => {
  719. this.volumeSliderValue = Math.max(
  720. 0,
  721. this.volumeSliderValue - 100
  722. );
  723. this.changeVolume();
  724. }
  725. });
  726. keyboardShortcuts.registerShortcut("editSong.increaseVolumeLarge", {
  727. keyCode: 104,
  728. preventDefault: true,
  729. handler: () => {
  730. this.volumeSliderValue = Math.min(
  731. 10000,
  732. this.volumeSliderValue + 1000
  733. );
  734. this.changeVolume();
  735. }
  736. });
  737. keyboardShortcuts.registerShortcut("editSong.increaseVolumeSmall", {
  738. keyCode: 104,
  739. ctrl: true,
  740. preventDefault: true,
  741. handler: () => {
  742. this.volumeSliderValue = Math.min(
  743. 10000,
  744. this.volumeSliderValue + 100
  745. );
  746. this.changeVolume();
  747. }
  748. });
  749. keyboardShortcuts.registerShortcut("editSong.save", {
  750. keyCode: 83,
  751. ctrl: true,
  752. preventDefault: true,
  753. handler: () => {
  754. this.save(this.song, false, false);
  755. }
  756. });
  757. keyboardShortcuts.registerShortcut("editSong.saveClose", {
  758. keyCode: 83,
  759. ctrl: true,
  760. alt: true,
  761. preventDefault: true,
  762. handler: () => {
  763. this.save(this.song, true);
  764. }
  765. });
  766. keyboardShortcuts.registerShortcut("editSong.saveVerifyClose", {
  767. keyCode: 86,
  768. ctrl: true,
  769. alt: true,
  770. preventDefault: true,
  771. handler: () => {
  772. // alert("not implemented yet");
  773. }
  774. });
  775. keyboardShortcuts.registerShortcut("editSong.close", {
  776. keyCode: 115,
  777. preventDefault: true,
  778. handler: () => {
  779. this.closeModal("editSong");
  780. setTimeout(() => {
  781. window.focusedElementBefore.focus();
  782. }, 500);
  783. }
  784. });
  785. keyboardShortcuts.registerShortcut("editSong.focusTitle", {
  786. keyCode: 36,
  787. preventDefault: true,
  788. handler: () => {
  789. this.$refs["title-input"].focus();
  790. }
  791. });
  792. keyboardShortcuts.registerShortcut("editSong.useAllDiscogs", {
  793. keyCode: 68,
  794. alt: true,
  795. ctrl: true,
  796. preventDefault: true,
  797. handler: () => {
  798. this.getAlbumData("title");
  799. this.getAlbumData("albumArt");
  800. this.getAlbumData("artists");
  801. this.getAlbumData("genres");
  802. }
  803. });
  804. /*
  805. editSong.pauseResume - Num 5 - Pause/resume song
  806. editSong.stopVideo - Ctrl - Num 5 - Stop
  807. editSong.skipToLast10Secs - Num 6 - Skip to last 10 seconds
  808. editSong.lowerVolumeLarge - Num 2 - Volume down by 10
  809. editSong.lowerVolumeSmall - Ctrl - Num 2 - Volume down by 1
  810. editSong.increaseVolumeLarge - Num 8 - Volume up by 10
  811. editSong.increaseVolumeSmall - Ctrl - Num 8 - Volume up by 1
  812. editSong.focusTitle - Home - Focus the title input
  813. editSong.focusDicogs - End - Focus the discogs input
  814. editSong.save - Ctrl - S - Saves song
  815. editSong.save - Ctrl - Alt - S - Saves song and closes the modal
  816. editSong.save - Ctrl - Alt - V - Saves song, verifies songs and then closes the modal
  817. editSong.close - F4 - Closes modal without saving
  818. editSong.useAllDiscogs - Ctrl - Alt - D - Sets all fields to the Discogs data
  819. Inside Discogs inputs: Ctrl - D - Sets this field to the Discogs data
  820. */
  821. },
  822. beforeUnmount() {
  823. this.video.player.stopVideo();
  824. this.playerReady = false;
  825. clearInterval(this.interval);
  826. clearInterval(this.activityWatchVideoDataInterval);
  827. this.socket.dispatch("apis.leaveRoom", `edit-song.${this.song._id}`);
  828. const shortcutNames = [
  829. "editSong.pauseResume",
  830. "editSong.stopVideo",
  831. "editSong.skipToLast10Secs",
  832. "editSong.lowerVolumeLarge",
  833. "editSong.lowerVolumeSmall",
  834. "editSong.increaseVolumeLarge",
  835. "editSong.increaseVolumeSmall",
  836. "editSong.focusTitle",
  837. "editSong.focusDicogs",
  838. "editSong.save",
  839. "editSong.saveClose",
  840. "editSong.saveVerifyClose",
  841. "editSong.close",
  842. "editSong.useAllDiscogs"
  843. ];
  844. shortcutNames.forEach(shortcutName => {
  845. keyboardShortcuts.unregisterShortcut(shortcutName);
  846. });
  847. },
  848. methods: {
  849. init() {
  850. this.socket.dispatch(
  851. `songs.getSongFromSongId`,
  852. this.song._id,
  853. res => {
  854. if (res.status === "success") {
  855. const { song } = res.data;
  856. // this.song = { ...song };
  857. // if (this.song.discogs === undefined)
  858. // this.song.discogs = null;
  859. if (this.song.discogs)
  860. this.editSong({
  861. ...song,
  862. discogs: this.song.discogs
  863. });
  864. else this.editSong(song);
  865. this.songDataLoaded = true;
  866. this.socket.dispatch(
  867. "apis.joinRoom",
  868. `edit-song.${this.song._id}`
  869. );
  870. // this.edit(res.data.song);
  871. this.interval = setInterval(() => {
  872. if (
  873. this.song.duration !== -1 &&
  874. this.video.paused === false &&
  875. this.playerReady &&
  876. (this.video.player.getCurrentTime() -
  877. this.song.skipDuration >
  878. this.song.duration ||
  879. (this.video.player.getCurrentTime() > 0 &&
  880. this.video.player.getCurrentTime() >=
  881. this.video.player.getDuration()))
  882. ) {
  883. this.video.paused = true;
  884. this.video.player.stopVideo();
  885. this.drawCanvas();
  886. }
  887. if (this.playerReady) {
  888. this.youtubeVideoCurrentTime = this.video.player
  889. .getCurrentTime()
  890. .toFixed(3);
  891. }
  892. if (this.video.paused === false) this.drawCanvas();
  893. }, 200);
  894. if (window.YT && window.YT.Player) {
  895. this.video.player = new window.YT.Player(
  896. "editSongPlayer",
  897. {
  898. height: 270,
  899. width: 480,
  900. videoId: this.song.youtubeId,
  901. host: "https://www.youtube-nocookie.com",
  902. playerVars: {
  903. controls: 0,
  904. iv_load_policy: 3,
  905. rel: 0,
  906. showinfo: 0,
  907. autoplay: 0
  908. },
  909. startSeconds: this.song.skipDuration,
  910. events: {
  911. onReady: () => {
  912. let volume = parseInt(
  913. localStorage.getItem("volume")
  914. );
  915. volume =
  916. typeof volume === "number"
  917. ? volume
  918. : 20;
  919. this.video.player.setVolume(volume);
  920. if (volume > 0)
  921. this.video.player.unMute();
  922. const duration =
  923. this.video.player.getDuration();
  924. this.youtubeVideoDuration =
  925. duration.toFixed(3);
  926. this.youtubeVideoNote = "(~)";
  927. this.playerReady = true;
  928. this.drawCanvas();
  929. },
  930. onStateChange: event => {
  931. this.drawCanvas();
  932. let skipToLast10SecsPressed = false;
  933. if (
  934. event.data === 1 &&
  935. this.skipToLast10SecsPressed
  936. ) {
  937. this.skipToLast10SecsPressed = false;
  938. skipToLast10SecsPressed = true;
  939. }
  940. if (
  941. event.data === 1 &&
  942. !skipToLast10SecsPressed
  943. ) {
  944. this.video.paused = false;
  945. let youtubeDuration =
  946. this.video.player.getDuration();
  947. const newYoutubeVideoDuration =
  948. youtubeDuration.toFixed(3);
  949. const songDurationNumber =
  950. Number(this.song.duration);
  951. const songDurationNumber2 =
  952. Number(this.song.duration) +
  953. 1;
  954. const songDurationNumber3 =
  955. Number(this.song.duration) -
  956. 1;
  957. const fixedSongDuration =
  958. songDurationNumber.toFixed(
  959. 3
  960. );
  961. const fixedSongDuration2 =
  962. songDurationNumber2.toFixed(
  963. 3
  964. );
  965. const fixedSongDuration3 =
  966. songDurationNumber3.toFixed(
  967. 3
  968. );
  969. if (
  970. this
  971. .youtubeVideoDuration !==
  972. newYoutubeVideoDuration &&
  973. (fixedSongDuration ===
  974. this
  975. .youtubeVideoDuration ||
  976. fixedSongDuration2 ===
  977. this
  978. .youtubeVideoDuration ||
  979. fixedSongDuration3 ===
  980. this
  981. .youtubeVideoDuration)
  982. )
  983. this.song.duration =
  984. newYoutubeVideoDuration;
  985. this.youtubeVideoDuration =
  986. newYoutubeVideoDuration;
  987. this.youtubeVideoNote = "";
  988. if (this.song.duration === -1)
  989. this.song.duration =
  990. youtubeDuration;
  991. youtubeDuration -=
  992. this.song.skipDuration;
  993. if (
  994. this.song.duration >
  995. youtubeDuration + 1
  996. ) {
  997. this.video.player.stopVideo();
  998. this.video.paused = true;
  999. return new Toast(
  1000. "Video can't play. Specified duration is bigger than the YouTube song duration."
  1001. );
  1002. }
  1003. if (this.song.duration <= 0) {
  1004. this.video.player.stopVideo();
  1005. this.video.paused = true;
  1006. return new Toast(
  1007. "Video can't play. Specified duration has to be more than 0 seconds."
  1008. );
  1009. }
  1010. if (
  1011. this.video.player.getCurrentTime() <
  1012. this.song.skipDuration
  1013. ) {
  1014. return this.video.player.seekTo(
  1015. this.song.skipDuration
  1016. );
  1017. }
  1018. } else if (event.data === 2) {
  1019. this.video.paused = true;
  1020. }
  1021. return false;
  1022. }
  1023. }
  1024. }
  1025. );
  1026. } else {
  1027. this.youtubeError = true;
  1028. this.youtubeErrorMessage =
  1029. "Player could not be loaded.";
  1030. }
  1031. } else {
  1032. new Toast("Song with that ID not found");
  1033. this.closeModal("editSong");
  1034. }
  1035. }
  1036. );
  1037. this.socket.dispatch(
  1038. "reports.getReportsForSong",
  1039. this.song._id,
  1040. res => {
  1041. this.updateReports(res.data.reports);
  1042. }
  1043. );
  1044. },
  1045. stopEditingSongs() {
  1046. this.updateEditingSongs(false);
  1047. this.closeModal("editSong");
  1048. },
  1049. importAlbum(result) {
  1050. this.selectDiscogsAlbum(result);
  1051. this.openModal("importAlbum");
  1052. this.closeModal("editSong");
  1053. },
  1054. save(songToCopy, verify, close) {
  1055. const song = JSON.parse(JSON.stringify(songToCopy));
  1056. let saveButtonRef = this.$refs.saveButton;
  1057. if (close && !verify) saveButtonRef = this.$refs.saveAndCloseButton;
  1058. else if (close && verify)
  1059. saveButtonRef = this.$refs.saveVerifyAndCloseButton;
  1060. if (!this.youtubeError && this.youtubeVideoDuration === "0.000") {
  1061. saveButtonRef.handleFailedSave();
  1062. return new Toast("The video appears to not be working.");
  1063. }
  1064. if (!song.title) {
  1065. saveButtonRef.handleFailedSave();
  1066. return new Toast("Please fill in all fields");
  1067. }
  1068. if (!song.thumbnail) {
  1069. saveButtonRef.handleFailedSave();
  1070. return new Toast("Please fill in all fields");
  1071. }
  1072. // const thumbnailHeight = this.$refs.thumbnailElement.naturalHeight;
  1073. // const thumbnailWidth = this.$refs.thumbnailElement.naturalWidth;
  1074. // if (thumbnailHeight < 80 || thumbnailWidth < 80) {
  1075. // saveButtonRef.handleFailedSave();
  1076. // return new Toast(
  1077. // "Thumbnail width and height must be at least 80px."
  1078. // );
  1079. // }
  1080. // if (thumbnailHeight > 4000 || thumbnailWidth > 4000) {
  1081. // saveButtonRef.handleFailedSave();
  1082. // return new Toast(
  1083. // "Thumbnail width and height must be less than 4000px."
  1084. // );
  1085. // }
  1086. // if (thumbnailHeight - thumbnailWidth > 5) {
  1087. // saveButtonRef.handleFailedSave();
  1088. // return new Toast("Thumbnail cannot be taller than it is wide.");
  1089. // }
  1090. // Youtube Id
  1091. if (
  1092. this.youtubeError &&
  1093. this.originalSong.youtubeId !== song.youtubeId
  1094. ) {
  1095. saveButtonRef.handleFailedSave();
  1096. return new Toast(
  1097. "You're not allowed to change the YouTube id while the player is not working"
  1098. );
  1099. }
  1100. // Duration
  1101. if (
  1102. Number(song.skipDuration) + Number(song.duration) >
  1103. this.youtubeVideoDuration &&
  1104. (!this.youtubeError ||
  1105. this.originalSong.duration !== song.duration)
  1106. ) {
  1107. saveButtonRef.handleFailedSave();
  1108. return new Toast(
  1109. "Duration can't be higher than the length of the video"
  1110. );
  1111. }
  1112. // Title
  1113. if (!validation.isLength(song.title, 1, 100)) {
  1114. saveButtonRef.handleFailedSave();
  1115. return new Toast(
  1116. "Title must have between 1 and 100 characters."
  1117. );
  1118. }
  1119. // Artists
  1120. if (song.artists.length < 1 || song.artists.length > 10) {
  1121. saveButtonRef.handleFailedSave();
  1122. return new Toast(
  1123. "Invalid artists. You must have at least 1 artist and a maximum of 10 artists."
  1124. );
  1125. }
  1126. let error;
  1127. song.artists.forEach(artist => {
  1128. if (!validation.isLength(artist, 1, 64)) {
  1129. error = "Artist must have between 1 and 64 characters.";
  1130. return error;
  1131. }
  1132. if (artist === "NONE") {
  1133. error =
  1134. 'Invalid artist format. Artists are not allowed to be named "NONE".';
  1135. return error;
  1136. }
  1137. return false;
  1138. });
  1139. if (error) {
  1140. saveButtonRef.handleFailedSave();
  1141. return new Toast(error);
  1142. }
  1143. // Genres
  1144. error = undefined;
  1145. song.genres.forEach(genre => {
  1146. if (!validation.isLength(genre, 1, 32)) {
  1147. error = "Genre must have between 1 and 32 characters.";
  1148. return error;
  1149. }
  1150. if (!validation.regex.ascii.test(genre)) {
  1151. error =
  1152. "Invalid genre format. Only ascii characters are allowed.";
  1153. return error;
  1154. }
  1155. return false;
  1156. });
  1157. if (song.genres.length < 1 || song.genres.length > 16)
  1158. error = "You must have between 1 and 16 genres.";
  1159. if (error) {
  1160. saveButtonRef.handleFailedSave();
  1161. return new Toast(error);
  1162. }
  1163. // Thumbnail
  1164. if (!validation.isLength(song.thumbnail, 1, 256)) {
  1165. saveButtonRef.handleFailedSave();
  1166. return new Toast(
  1167. "Thumbnail must have between 8 and 256 characters."
  1168. );
  1169. }
  1170. if (this.useHTTPS && song.thumbnail.indexOf("https://") !== 0) {
  1171. saveButtonRef.handleFailedSave();
  1172. return new Toast('Thumbnail must start with "https://".');
  1173. }
  1174. if (
  1175. !this.useHTTPS &&
  1176. song.thumbnail.indexOf("http://") !== 0 &&
  1177. song.thumbnail.indexOf("https://") !== 0
  1178. ) {
  1179. saveButtonRef.handleFailedSave();
  1180. return new Toast('Thumbnail must start with "http://".');
  1181. }
  1182. saveButtonRef.status = "disabled";
  1183. return this.socket.dispatch(`songs.update`, song._id, song, res => {
  1184. new Toast(res.message);
  1185. if (res.status === "success")
  1186. saveButtonRef.handleSuccessfulSave();
  1187. else saveButtonRef.handleFailedSave();
  1188. if (verify) this.verify(this.song._id);
  1189. if (close) this.closeModal("editSong");
  1190. });
  1191. },
  1192. getAlbumData(type) {
  1193. if (!this.song.discogs) return;
  1194. if (type === "title")
  1195. this.updateSongField({
  1196. field: "title",
  1197. value: this.song.discogs.track.title
  1198. });
  1199. if (type === "albumArt")
  1200. this.updateSongField({
  1201. field: "thumbnail",
  1202. value: this.song.discogs.album.albumArt
  1203. });
  1204. if (type === "genres")
  1205. this.updateSongField({
  1206. field: "genres",
  1207. value: JSON.parse(
  1208. JSON.stringify(this.song.discogs.album.genres)
  1209. )
  1210. });
  1211. if (type === "artists")
  1212. this.updateSongField({
  1213. field: "artists",
  1214. value: JSON.parse(
  1215. JSON.stringify(this.song.discogs.album.artists)
  1216. )
  1217. });
  1218. },
  1219. fillDuration() {
  1220. this.song.duration =
  1221. this.youtubeVideoDuration - this.song.skipDuration;
  1222. },
  1223. blurArtistInput() {
  1224. this.artistInputFocussed = false;
  1225. },
  1226. focusArtistInput() {
  1227. this.artistInputFocussed = true;
  1228. },
  1229. blurArtistContainer() {
  1230. this.artistAutosuggestContainerFocussed = false;
  1231. },
  1232. focusArtistContainer() {
  1233. this.artistAutosuggestContainerFocussed = true;
  1234. },
  1235. keydownArtistInput() {
  1236. clearTimeout(this.keydownArtistInputTimeout);
  1237. this.keydownArtistInputTimeout = setTimeout(() => {
  1238. // Do things here to query the artist
  1239. }, 1000);
  1240. },
  1241. blurGenreInput() {
  1242. this.genreInputFocussed = false;
  1243. },
  1244. focusGenreInput() {
  1245. this.genreInputFocussed = true;
  1246. },
  1247. blurGenreContainer() {
  1248. this.genreAutosuggestContainerFocussed = false;
  1249. },
  1250. focusGenreContainer() {
  1251. this.genreAutosuggestContainerFocussed = true;
  1252. },
  1253. keydownGenreInput() {
  1254. clearTimeout(this.keydownGenreInputTimeout);
  1255. this.keydownGenreInputTimeout = setTimeout(() => {
  1256. if (this.genreInputValue.length > 1) {
  1257. this.genreAutosuggestItems = this.genres.filter(genre =>
  1258. genre
  1259. .toLowerCase()
  1260. .startsWith(this.genreInputValue.toLowerCase())
  1261. );
  1262. } else this.genreAutosuggestItems = [];
  1263. }, 1000);
  1264. },
  1265. settings(type) {
  1266. switch (type) {
  1267. default:
  1268. break;
  1269. case "stop":
  1270. this.stopVideo();
  1271. this.pauseVideo(true);
  1272. break;
  1273. case "pause":
  1274. this.pauseVideo(true);
  1275. break;
  1276. case "play":
  1277. this.pauseVideo(false);
  1278. break;
  1279. case "skipToLast10Secs":
  1280. this.skipToLast10SecsPressed = true;
  1281. if (this.video.paused) this.pauseVideo(false);
  1282. this.video.player.seekTo(
  1283. this.song.duration - 10 + this.song.skipDuration
  1284. );
  1285. break;
  1286. }
  1287. },
  1288. play() {
  1289. if (
  1290. this.video.player.getVideoData().video_id !==
  1291. this.song.youtubeId
  1292. ) {
  1293. this.song.duration = -1;
  1294. this.loadVideoById(this.song.youtubeId, this.song.skipDuration);
  1295. }
  1296. this.settings("play");
  1297. },
  1298. changeVolume() {
  1299. const volume = this.volumeSliderValue;
  1300. localStorage.setItem("volume", volume / 100);
  1301. this.video.player.setVolume(volume / 100);
  1302. if (volume > 0) {
  1303. this.video.player.unMute();
  1304. this.muted = false;
  1305. }
  1306. },
  1307. toggleMute() {
  1308. const previousVolume = parseFloat(localStorage.getItem("volume"));
  1309. const volume =
  1310. this.video.player.getVolume() * 100 <= 0 ? previousVolume : 0;
  1311. this.muted = !this.muted;
  1312. this.volumeSliderValue = volume * 100;
  1313. this.video.player.setVolume(volume);
  1314. if (!this.muted) localStorage.setItem("volume", volume);
  1315. },
  1316. increaseVolume() {
  1317. const previousVolume = parseInt(localStorage.getItem("volume"));
  1318. let volume = previousVolume + 5;
  1319. this.muted = false;
  1320. if (volume > 100) volume = 100;
  1321. this.volumeSliderValue = volume * 100;
  1322. this.video.player.setVolume(volume);
  1323. localStorage.setItem("volume", volume);
  1324. },
  1325. addTag(type, value) {
  1326. if (type === "genres") {
  1327. const genre = value || this.genreInputValue.trim();
  1328. if (
  1329. this.song.genres
  1330. .map(genre => genre.toLowerCase())
  1331. .indexOf(genre.toLowerCase()) !== -1
  1332. )
  1333. return new Toast("Genre already exists");
  1334. if (genre) {
  1335. this.song.genres.push(genre);
  1336. this.genreInputValue = "";
  1337. this.genreAutosuggestItems = [];
  1338. return false;
  1339. }
  1340. return new Toast("Genre cannot be empty");
  1341. }
  1342. if (type === "artists") {
  1343. const artist = value || this.artistInputValue;
  1344. if (this.song.artists.indexOf(artist) !== -1)
  1345. return new Toast("Artist already exists");
  1346. if (artist !== "") {
  1347. this.song.artists.push(artist);
  1348. this.artistInputValue = "";
  1349. this.artistAutosuggestItems = [];
  1350. return false;
  1351. }
  1352. return new Toast("Artist cannot be empty");
  1353. }
  1354. return false;
  1355. },
  1356. removeTag(type, value) {
  1357. if (type === "genres")
  1358. this.song.genres.splice(this.song.genres.indexOf(value), 1);
  1359. else if (type === "artists")
  1360. this.song.artists.splice(this.song.artists.indexOf(value), 1);
  1361. },
  1362. drawCanvas() {
  1363. const canvasElement = this.$refs.durationCanvas;
  1364. const ctx = canvasElement.getContext("2d");
  1365. const videoDuration = Number(this.youtubeVideoDuration);
  1366. const skipDuration = Number(this.song.skipDuration);
  1367. const duration = Number(this.song.duration);
  1368. const afterDuration = videoDuration - (skipDuration + duration);
  1369. const width = 530;
  1370. const currentTime =
  1371. this.video.player && this.video.player.getCurrentTime
  1372. ? this.video.player.getCurrentTime()
  1373. : 0;
  1374. const widthSkipDuration = (skipDuration / videoDuration) * width;
  1375. const widthDuration = (duration / videoDuration) * width;
  1376. const widthAfterDuration = (afterDuration / videoDuration) * width;
  1377. const widthCurrentTime = (currentTime / videoDuration) * width;
  1378. const skipDurationColor = "#F42003";
  1379. const durationColor = "#03A9F4";
  1380. const afterDurationColor = "#41E841";
  1381. const currentDurationColor = "#3b25e8";
  1382. ctx.fillStyle = skipDurationColor;
  1383. ctx.fillRect(0, 0, widthSkipDuration, 20);
  1384. ctx.fillStyle = durationColor;
  1385. ctx.fillRect(widthSkipDuration, 0, widthDuration, 20);
  1386. ctx.fillStyle = afterDurationColor;
  1387. ctx.fillRect(
  1388. widthSkipDuration + widthDuration,
  1389. 0,
  1390. widthAfterDuration,
  1391. 20
  1392. );
  1393. ctx.fillStyle = currentDurationColor;
  1394. ctx.fillRect(widthCurrentTime, 0, 1, 20);
  1395. },
  1396. toggleGenreHelper() {
  1397. this.$refs.genreHelper.toggleBox();
  1398. },
  1399. resetGenreHelper() {
  1400. this.$refs.genreHelper.resetBox();
  1401. },
  1402. sendActivityWatchVideoData() {
  1403. if (!this.video.paused) {
  1404. if (this.activityWatchVideoLastStatus !== "playing") {
  1405. this.activityWatchVideoLastStatus = "playing";
  1406. if (
  1407. this.song.skipDuration > 0 &&
  1408. parseFloat(this.youtubeVideoCurrentTime) === 0
  1409. ) {
  1410. this.activityWatchVideoLastStartDuration = Math.floor(
  1411. this.song.skipDuration +
  1412. parseFloat(this.youtubeVideoCurrentTime)
  1413. );
  1414. } else {
  1415. this.activityWatchVideoLastStartDuration = Math.floor(
  1416. parseFloat(this.youtubeVideoCurrentTime)
  1417. );
  1418. }
  1419. }
  1420. const videoData = {
  1421. title: this.song.title,
  1422. artists: this.song.artists
  1423. ? this.song.artists.join(", ")
  1424. : null,
  1425. youtubeId: this.song.youtubeId,
  1426. muted: this.muted,
  1427. volume: this.volumeSliderValue / 100,
  1428. startedDuration:
  1429. this.activityWatchVideoLastStartDuration <= 0
  1430. ? 0
  1431. : this.activityWatchVideoLastStartDuration,
  1432. source: `editSong#${this.song.youtubeId}`,
  1433. hostname: window.location.hostname
  1434. };
  1435. aw.sendVideoData(videoData);
  1436. } else {
  1437. this.activityWatchVideoLastStatus = "not_playing";
  1438. }
  1439. },
  1440. verify(id) {
  1441. this.socket.dispatch("songs.verify", id, res => {
  1442. new Toast(res.message);
  1443. });
  1444. },
  1445. unverify(id) {
  1446. this.socket.dispatch("songs.unverify", id, res => {
  1447. new Toast(res.message);
  1448. });
  1449. },
  1450. hide(id) {
  1451. this.socket.dispatch("songs.hide", id, res => {
  1452. new Toast(res.message);
  1453. });
  1454. },
  1455. unhide(id) {
  1456. this.socket.dispatch("songs.unhide", id, res => {
  1457. new Toast(res.message);
  1458. });
  1459. },
  1460. // remove(id) {
  1461. // this.socket.dispatch("songs.remove", id, res => {
  1462. // new Toast(res.message);
  1463. // });
  1464. // },
  1465. ...mapActions("modals/importAlbum", [
  1466. "selectDiscogsAlbum",
  1467. "updateEditingSongs"
  1468. ]),
  1469. ...mapActions({
  1470. showTab(dispatch, payload) {
  1471. this.$refs[`${payload}-tab`].scrollIntoView();
  1472. return dispatch("modals/editSong/showTab", payload);
  1473. }
  1474. }),
  1475. ...mapActions("modals/editSong", [
  1476. "stopVideo",
  1477. "loadVideoById",
  1478. "pauseVideo",
  1479. "getCurrentTime",
  1480. "editSong",
  1481. "updateSongField",
  1482. "updateReports"
  1483. ]),
  1484. ...mapActions("modalVisibility", ["closeModal", "openModal"])
  1485. }
  1486. };
  1487. </script>
  1488. <style lang="scss">
  1489. #editSongPlayer {
  1490. position: absolute;
  1491. top: 0;
  1492. left: 0;
  1493. width: 100%;
  1494. height: 100%;
  1495. }
  1496. </style>
  1497. <style lang="scss" scoped>
  1498. .night-mode {
  1499. .edit-section,
  1500. .player-footer,
  1501. #tabs-container {
  1502. background-color: var(--dark-grey-3) !important;
  1503. border: 0 !important;
  1504. .tab {
  1505. border: 0 !important;
  1506. }
  1507. }
  1508. .autosuggest-container {
  1509. background-color: unset !important;
  1510. }
  1511. .autosuggest-item {
  1512. background-color: var(--dark-grey) !important;
  1513. color: white !important;
  1514. border-color: var(--dark-grey) !important;
  1515. }
  1516. .autosuggest-item:hover,
  1517. .autosuggest-item:focus {
  1518. background-color: var(--dark-grey-2) !important;
  1519. }
  1520. #tabs-container #tab-selection .button {
  1521. background: var(--dark-grey) !important;
  1522. color: var(--white) !important;
  1523. }
  1524. }
  1525. .song-modal {
  1526. &::v-deep {
  1527. .modal-card {
  1528. width: 1300px;
  1529. height: 100%;
  1530. .modal-card-body {
  1531. display: flex;
  1532. column-gap: 16px;
  1533. row-gap: 16px;
  1534. @media screen and (max-width: 1000px) {
  1535. flex-wrap: wrap;
  1536. }
  1537. > div {
  1538. display: flex;
  1539. flex-grow: 1;
  1540. height: 100%;
  1541. overflow: auto;
  1542. }
  1543. }
  1544. .modal-card-foot {
  1545. .right {
  1546. display: flex;
  1547. margin-left: auto;
  1548. margin-right: 0;
  1549. }
  1550. }
  1551. }
  1552. }
  1553. }
  1554. #video-container {
  1555. position: relative;
  1556. padding-bottom: 56.25%; /* proportion value to aspect ratio 16:9 (9 / 16 = 0.5625 or 56.25%) */
  1557. height: 0;
  1558. overflow: hidden;
  1559. .player-cannot-autoplay {
  1560. position: relative;
  1561. width: 100%;
  1562. height: 100%;
  1563. bottom: calc(100% + 5px);
  1564. background-color: var(--primary-color);
  1565. display: flex;
  1566. align-items: center;
  1567. justify-content: center;
  1568. p {
  1569. color: var(--white);
  1570. font-size: 26px;
  1571. text-align: center;
  1572. }
  1573. }
  1574. }
  1575. .left-section {
  1576. display: flex;
  1577. flex-direction: column;
  1578. flex-grow: 0 !important;
  1579. height: inherit !important;
  1580. @media screen and (max-width: 1245px) {
  1581. flex-grow: 1 !important;
  1582. }
  1583. .top-section {
  1584. display: flex;
  1585. flex-direction: column;
  1586. .player-section {
  1587. display: flex;
  1588. flex-direction: column;
  1589. .player-error {
  1590. height: 318px;
  1591. // width: 530px;
  1592. display: block;
  1593. border: 1px rgba(163, 224, 255, 0.75) solid;
  1594. border-radius: 5px 5px 0px 0px;
  1595. display: flex;
  1596. align-items: center;
  1597. * {
  1598. margin: 0;
  1599. flex: 1;
  1600. font-size: 30px;
  1601. text-align: center;
  1602. }
  1603. }
  1604. #durationCanvas {
  1605. max-width: 100%;
  1606. }
  1607. .player-footer {
  1608. border: 1px solid var(--light-grey-3);
  1609. border-radius: 0px 0px 3px 3px;
  1610. display: flex;
  1611. justify-content: space-between;
  1612. padding: 10px;
  1613. width: 100%;
  1614. background-color: var(--white);
  1615. flex-direction: column;
  1616. flex-flow: wrap;
  1617. > * {
  1618. display: flex;
  1619. align-items: center;
  1620. }
  1621. .player-footer-left {
  1622. flex: 1;
  1623. .button {
  1624. width: 75px;
  1625. &:not(:first-of-type) {
  1626. margin-left: 5px;
  1627. }
  1628. }
  1629. }
  1630. .player-footer-center {
  1631. justify-content: center;
  1632. align-items: center;
  1633. flex: 2;
  1634. font-size: 21px;
  1635. font-weight: 400;
  1636. width: 200px;
  1637. img {
  1638. height: 21px;
  1639. margin-right: 12px;
  1640. filter: invert(26%) sepia(54%) saturate(6317%)
  1641. hue-rotate(2deg) brightness(92%) contrast(115%);
  1642. }
  1643. }
  1644. .player-footer-right {
  1645. justify-content: right;
  1646. flex: 1;
  1647. #volume-control {
  1648. margin: 3px;
  1649. margin-top: 0;
  1650. display: flex;
  1651. align-items: center;
  1652. cursor: pointer;
  1653. .volume-slider {
  1654. width: 100%;
  1655. padding: 0 15px;
  1656. background: transparent;
  1657. min-width: 100px;
  1658. }
  1659. input[type="range"] {
  1660. -webkit-appearance: none;
  1661. margin: 7.3px 0;
  1662. }
  1663. input[type="range"]:focus {
  1664. outline: none;
  1665. }
  1666. input[type="range"]::-webkit-slider-runnable-track {
  1667. width: 100%;
  1668. height: 5.2px;
  1669. cursor: pointer;
  1670. box-shadow: 0;
  1671. background: var(--light-grey-3);
  1672. border-radius: 0;
  1673. border: 0;
  1674. }
  1675. input[type="range"]::-webkit-slider-thumb {
  1676. box-shadow: 0;
  1677. border: 0;
  1678. height: 19px;
  1679. width: 19px;
  1680. border-radius: 15px;
  1681. background: var(--primary-color);
  1682. cursor: pointer;
  1683. -webkit-appearance: none;
  1684. margin-top: -6.5px;
  1685. }
  1686. input[type="range"]::-moz-range-track {
  1687. width: 100%;
  1688. height: 5.2px;
  1689. cursor: pointer;
  1690. box-shadow: 0;
  1691. background: var(--light-grey-3);
  1692. border-radius: 0;
  1693. border: 0;
  1694. }
  1695. input[type="range"]::-moz-range-thumb {
  1696. box-shadow: 0;
  1697. border: 0;
  1698. height: 19px;
  1699. width: 19px;
  1700. border-radius: 15px;
  1701. background: var(--primary-color);
  1702. cursor: pointer;
  1703. -webkit-appearance: none;
  1704. margin-top: -6.5px;
  1705. }
  1706. input[type="range"]::-ms-track {
  1707. width: 100%;
  1708. height: 5.2px;
  1709. cursor: pointer;
  1710. box-shadow: 0;
  1711. background: var(--light-grey-3);
  1712. border-radius: 1.3px;
  1713. }
  1714. input[type="range"]::-ms-fill-lower {
  1715. background: var(--light-grey-3);
  1716. border: 0;
  1717. border-radius: 0;
  1718. box-shadow: 0;
  1719. }
  1720. input[type="range"]::-ms-fill-upper {
  1721. background: var(--light-grey-3);
  1722. border: 0;
  1723. border-radius: 0;
  1724. box-shadow: 0;
  1725. }
  1726. input[type="range"]::-ms-thumb {
  1727. box-shadow: 0;
  1728. border: 0;
  1729. height: 15px;
  1730. width: 15px;
  1731. border-radius: 15px;
  1732. background: var(--primary-color);
  1733. cursor: pointer;
  1734. -webkit-appearance: none;
  1735. margin-top: 1.5px;
  1736. }
  1737. }
  1738. }
  1739. }
  1740. }
  1741. }
  1742. .edit-section {
  1743. border: 1px solid var(--light-grey-3);
  1744. margin-top: 16px;
  1745. border-radius: 3px;
  1746. .album-get-button {
  1747. background-color: var(--purple);
  1748. color: var(--white);
  1749. width: 32px;
  1750. text-align: center;
  1751. border-width: 0;
  1752. }
  1753. .duration-fill-button {
  1754. background-color: var(--red);
  1755. color: var(--white);
  1756. width: 32px;
  1757. text-align: center;
  1758. border-width: 0;
  1759. }
  1760. .add-button {
  1761. background-color: var(--primary-color) !important;
  1762. width: 32px;
  1763. i {
  1764. font-size: 32px;
  1765. }
  1766. }
  1767. .album-get-button,
  1768. .duration-fill-button,
  1769. .add-button {
  1770. &:focus,
  1771. &:hover {
  1772. filter: contrast(0.75);
  1773. border: 1px solid var(--black) !important;
  1774. }
  1775. }
  1776. > div {
  1777. margin: 16px !important;
  1778. }
  1779. input {
  1780. width: 100%;
  1781. }
  1782. .title-container {
  1783. width: calc((100% - 32px) / 2);
  1784. }
  1785. .duration-container {
  1786. margin-right: 16px;
  1787. margin-left: 16px;
  1788. width: calc((100% - 32px) / 4);
  1789. }
  1790. .skip-duration-container {
  1791. width: calc((100% - 32px) / 4);
  1792. }
  1793. .album-art-container {
  1794. display: flex;
  1795. flex-direction: column;
  1796. div {
  1797. display: flex;
  1798. flex-direction: row;
  1799. align-items: center;
  1800. .thumbnail-preview {
  1801. border: 1px solid var(--light-grey-3);
  1802. width: 75px;
  1803. height: 75px;
  1804. }
  1805. .control {
  1806. margin-left: 20px;
  1807. width: 100%;
  1808. }
  1809. }
  1810. }
  1811. .artists-container {
  1812. width: calc((100% - 32px) / 3);
  1813. position: relative;
  1814. }
  1815. .genres-container {
  1816. width: calc((100% - 32px) / 3);
  1817. margin-left: 16px;
  1818. margin-right: 16px;
  1819. position: relative;
  1820. label {
  1821. display: flex;
  1822. i {
  1823. font-size: 15px;
  1824. align-self: center;
  1825. margin-left: 5px;
  1826. color: var(--primary-color);
  1827. cursor: pointer;
  1828. -webkit-user-select: none;
  1829. -moz-user-select: none;
  1830. -ms-user-select: none;
  1831. user-select: none;
  1832. }
  1833. }
  1834. }
  1835. .youtube-id-container {
  1836. width: calc((100% - 32px) / 3);
  1837. }
  1838. .list-item-circle {
  1839. background-color: var(--primary-color);
  1840. width: 16px;
  1841. height: 16px;
  1842. border-radius: 8px;
  1843. cursor: pointer;
  1844. margin-right: 8px;
  1845. float: left;
  1846. -webkit-touch-callout: none;
  1847. -webkit-user-select: none;
  1848. -khtml-user-select: none;
  1849. -moz-user-select: none;
  1850. -ms-user-select: none;
  1851. user-select: none;
  1852. i {
  1853. color: var(--primary-color);
  1854. font-size: 14px;
  1855. margin-left: 1px;
  1856. position: relative;
  1857. top: -1px;
  1858. }
  1859. }
  1860. .list-item-circle:hover,
  1861. .list-item-circle:focus {
  1862. i {
  1863. color: var(--white);
  1864. }
  1865. }
  1866. .list-item > p {
  1867. line-height: 16px;
  1868. word-wrap: break-word;
  1869. width: calc(100% - 24px);
  1870. left: 24px;
  1871. float: left;
  1872. margin-bottom: 8px;
  1873. }
  1874. .list-item:last-child > p {
  1875. margin-bottom: 0;
  1876. }
  1877. .autosuggest-container {
  1878. position: absolute;
  1879. background: var(--white);
  1880. width: calc(100% + 1px);
  1881. top: 57px;
  1882. z-index: 200;
  1883. overflow: auto;
  1884. max-height: 100%;
  1885. clear: both;
  1886. .autosuggest-item {
  1887. padding: 8px;
  1888. display: block;
  1889. border: 1px solid var(--light-grey-2);
  1890. margin-top: -1px;
  1891. line-height: 16px;
  1892. cursor: pointer;
  1893. -webkit-user-select: none;
  1894. -ms-user-select: none;
  1895. -moz-user-select: none;
  1896. user-select: none;
  1897. }
  1898. .autosuggest-item:hover,
  1899. .autosuggest-item:focus {
  1900. background-color: var(--light-grey);
  1901. }
  1902. .autosuggest-item:first-child {
  1903. border-top: none;
  1904. }
  1905. .autosuggest-item:last-child {
  1906. border-radius: 0 0 3px 3px;
  1907. }
  1908. }
  1909. }
  1910. }
  1911. .right-section {
  1912. display: flex;
  1913. flex-wrap: wrap;
  1914. flex-basis: 450px;
  1915. overflow-y: auto;
  1916. @media screen and (max-width: 1245px) {
  1917. height: inherit !important;
  1918. }
  1919. #tabs-container {
  1920. overflow: auto;
  1921. display: flex;
  1922. flex-direction: column;
  1923. flex-grow: 1;
  1924. #tab-selection {
  1925. display: flex;
  1926. overflow-x: auto;
  1927. .button {
  1928. border-radius: 5px 5px 0 0;
  1929. border: 0;
  1930. text-transform: uppercase;
  1931. font-size: 14px;
  1932. color: var(--dark-grey-3);
  1933. background-color: var(--light-grey-2);
  1934. flex-grow: 1;
  1935. height: 32px;
  1936. &:not(:first-of-type) {
  1937. margin-left: 5px;
  1938. }
  1939. }
  1940. .selected {
  1941. background-color: var(--primary-color) !important;
  1942. color: var(--white) !important;
  1943. font-weight: 600;
  1944. }
  1945. }
  1946. .tab {
  1947. border: 1px solid var(--light-grey-3);
  1948. border-radius: 3px;
  1949. padding: 15px;
  1950. }
  1951. }
  1952. // .api-section {
  1953. // width: 376px;
  1954. // background-color: var(--light-grey);
  1955. // border: 1px rgba(163, 224, 255, 0.75) solid;
  1956. // border-radius: 5px;
  1957. // padding: 16px;
  1958. // overflow: auto;
  1959. // height: 100%;
  1960. // > label {
  1961. // margin-top: 12px;
  1962. // }
  1963. // .top-container {
  1964. // display: flex;
  1965. // img {
  1966. // height: 85px;
  1967. // width: 85px;
  1968. // }
  1969. // .right-container {
  1970. // padding: 8px;
  1971. // display: flex;
  1972. // flex-direction: column;
  1973. // flex: 1;
  1974. // .album-title {
  1975. // flex: 1;
  1976. // font-weight: 600;
  1977. // }
  1978. // .bottom-row {
  1979. // display: flex;
  1980. // flex-flow: row;
  1981. // line-height: 15px;
  1982. // img {
  1983. // height: 15px;
  1984. // align-self: end;
  1985. // flex: 1;
  1986. // user-select: none;
  1987. // -moz-user-select: none;
  1988. // -ms-user-select: none;
  1989. // -webkit-user-select: none;
  1990. // cursor: pointer;
  1991. // }
  1992. // p {
  1993. // text-align: right;
  1994. // }
  1995. // .type-year {
  1996. // font-size: 13px;
  1997. // align-self: end;
  1998. // }
  1999. // }
  2000. // }
  2001. // }
  2002. // .bottom-container {
  2003. // padding: 12px;
  2004. // .bottom-container-field {
  2005. // line-height: 16px;
  2006. // margin-bottom: 8px;
  2007. // font-weight: 600;
  2008. // span {
  2009. // font-weight: 400;
  2010. // }
  2011. // }
  2012. // .bottom-container-field:last-of-type {
  2013. // margin-bottom: 0;
  2014. // }
  2015. // }
  2016. // .selected-discogs-info {
  2017. // background-color: var(--white);
  2018. // border: 1px solid var(--purple);
  2019. // border-radius: 5px;
  2020. // margin-bottom: 16px;
  2021. // .selected-discogs-info-none {
  2022. // font-size: 18px;
  2023. // text-align: center;
  2024. // }
  2025. // .bottom-row > p {
  2026. // flex: 1;
  2027. // }
  2028. // }
  2029. // .api-result {
  2030. // background-color: var(--white);
  2031. // border: 0.5px solid var(--primary-color);
  2032. // border-radius: 5px;
  2033. // margin-bottom: 16px;
  2034. // }
  2035. // button {
  2036. // background-color: var(--primary-color) !important;
  2037. // &:focus,
  2038. // &:hover {
  2039. // filter: contrast(0.75);
  2040. // }
  2041. // }
  2042. // .tracks {
  2043. // margin-top: 12px;
  2044. // .track:first-child {
  2045. // margin-top: 0;
  2046. // border-radius: 3px 3px 0 0;
  2047. // }
  2048. // .track:last-child {
  2049. // border-radius: 0 0 3px 3px;
  2050. // }
  2051. // .track {
  2052. // border: 0.5px solid var(--black);
  2053. // margin-top: -1px;
  2054. // line-height: 16px;
  2055. // display: flex;
  2056. // cursor: pointer;
  2057. // span {
  2058. // font-weight: 600;
  2059. // display: inline-block;
  2060. // margin-top: 7px;
  2061. // margin-bottom: 7px;
  2062. // margin-left: 7px;
  2063. // }
  2064. // p {
  2065. // display: inline-block;
  2066. // margin: 7px;
  2067. // flex: 1;
  2068. // }
  2069. // }
  2070. // .track:hover,
  2071. // .track:focus {
  2072. // background-color: var(--light-grey);
  2073. // }
  2074. // }
  2075. // .discogs-load-more {
  2076. // margin-bottom: 8px;
  2077. // }
  2078. // }
  2079. }
  2080. .modal-card-foot .is-primary {
  2081. width: 200px;
  2082. }
  2083. </style>