1
0

index.vue 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300
  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. let { song } = res.data;
  856. if (this.song.prefill)
  857. song = Object.assign(song, this.song.prefill);
  858. if (this.song.discogs)
  859. song = {
  860. ...song,
  861. discogs: this.song.discogs
  862. };
  863. this.editSong(song);
  864. this.songDataLoaded = true;
  865. this.socket.dispatch(
  866. "apis.joinRoom",
  867. `edit-song.${this.song._id}`
  868. );
  869. this.interval = setInterval(() => {
  870. if (
  871. this.song.duration !== -1 &&
  872. this.video.paused === false &&
  873. this.playerReady &&
  874. (this.video.player.getCurrentTime() -
  875. this.song.skipDuration >
  876. this.song.duration ||
  877. (this.video.player.getCurrentTime() > 0 &&
  878. this.video.player.getCurrentTime() >=
  879. this.video.player.getDuration()))
  880. ) {
  881. this.video.paused = true;
  882. this.video.player.stopVideo();
  883. this.drawCanvas();
  884. }
  885. if (this.playerReady) {
  886. this.youtubeVideoCurrentTime = this.video.player
  887. .getCurrentTime()
  888. .toFixed(3);
  889. }
  890. if (this.video.paused === false) this.drawCanvas();
  891. }, 200);
  892. if (window.YT && window.YT.Player) {
  893. this.video.player = new window.YT.Player(
  894. "editSongPlayer",
  895. {
  896. height: 270,
  897. width: 480,
  898. videoId: this.song.youtubeId,
  899. host: "https://www.youtube-nocookie.com",
  900. playerVars: {
  901. controls: 0,
  902. iv_load_policy: 3,
  903. rel: 0,
  904. showinfo: 0,
  905. autoplay: 0
  906. },
  907. startSeconds: this.song.skipDuration,
  908. events: {
  909. onReady: () => {
  910. let volume = parseInt(
  911. localStorage.getItem("volume")
  912. );
  913. volume =
  914. typeof volume === "number"
  915. ? volume
  916. : 20;
  917. this.video.player.setVolume(volume);
  918. if (volume > 0)
  919. this.video.player.unMute();
  920. const duration =
  921. this.video.player.getDuration();
  922. this.youtubeVideoDuration =
  923. duration.toFixed(3);
  924. this.youtubeVideoNote = "(~)";
  925. this.playerReady = true;
  926. this.drawCanvas();
  927. },
  928. onStateChange: event => {
  929. this.drawCanvas();
  930. let skipToLast10SecsPressed = false;
  931. if (
  932. event.data === 1 &&
  933. this.skipToLast10SecsPressed
  934. ) {
  935. this.skipToLast10SecsPressed = false;
  936. skipToLast10SecsPressed = true;
  937. }
  938. if (
  939. event.data === 1 &&
  940. !skipToLast10SecsPressed
  941. ) {
  942. this.video.paused = false;
  943. let youtubeDuration =
  944. this.video.player.getDuration();
  945. const newYoutubeVideoDuration =
  946. youtubeDuration.toFixed(3);
  947. const songDurationNumber =
  948. Number(this.song.duration);
  949. const songDurationNumber2 =
  950. Number(this.song.duration) +
  951. 1;
  952. const songDurationNumber3 =
  953. Number(this.song.duration) -
  954. 1;
  955. const fixedSongDuration =
  956. songDurationNumber.toFixed(
  957. 3
  958. );
  959. const fixedSongDuration2 =
  960. songDurationNumber2.toFixed(
  961. 3
  962. );
  963. const fixedSongDuration3 =
  964. songDurationNumber3.toFixed(
  965. 3
  966. );
  967. if (
  968. this
  969. .youtubeVideoDuration !==
  970. newYoutubeVideoDuration &&
  971. (fixedSongDuration ===
  972. this
  973. .youtubeVideoDuration ||
  974. fixedSongDuration2 ===
  975. this
  976. .youtubeVideoDuration ||
  977. fixedSongDuration3 ===
  978. this
  979. .youtubeVideoDuration)
  980. )
  981. this.song.duration =
  982. newYoutubeVideoDuration;
  983. this.youtubeVideoDuration =
  984. newYoutubeVideoDuration;
  985. this.youtubeVideoNote = "";
  986. if (this.song.duration === -1)
  987. this.song.duration =
  988. youtubeDuration;
  989. youtubeDuration -=
  990. this.song.skipDuration;
  991. if (
  992. this.song.duration >
  993. youtubeDuration + 1
  994. ) {
  995. this.video.player.stopVideo();
  996. this.video.paused = true;
  997. return new Toast(
  998. "Video can't play. Specified duration is bigger than the YouTube song duration."
  999. );
  1000. }
  1001. if (this.song.duration <= 0) {
  1002. this.video.player.stopVideo();
  1003. this.video.paused = true;
  1004. return new Toast(
  1005. "Video can't play. Specified duration has to be more than 0 seconds."
  1006. );
  1007. }
  1008. if (
  1009. this.video.player.getCurrentTime() <
  1010. this.song.skipDuration
  1011. ) {
  1012. return this.video.player.seekTo(
  1013. this.song.skipDuration
  1014. );
  1015. }
  1016. } else if (event.data === 2) {
  1017. this.video.paused = true;
  1018. }
  1019. return false;
  1020. }
  1021. }
  1022. }
  1023. );
  1024. } else {
  1025. this.youtubeError = true;
  1026. this.youtubeErrorMessage =
  1027. "Player could not be loaded.";
  1028. }
  1029. } else {
  1030. new Toast("Song with that ID not found");
  1031. this.closeModal("editSong");
  1032. }
  1033. }
  1034. );
  1035. this.socket.dispatch(
  1036. "reports.getReportsForSong",
  1037. this.song._id,
  1038. res => {
  1039. this.updateReports(res.data.reports);
  1040. }
  1041. );
  1042. },
  1043. stopEditingSongs() {
  1044. this.updateEditingSongs(false);
  1045. this.closeModal("editSong");
  1046. },
  1047. importAlbum(result) {
  1048. this.selectDiscogsAlbum(result);
  1049. this.openModal("importAlbum");
  1050. this.closeModal("editSong");
  1051. },
  1052. save(songToCopy, verify, close) {
  1053. const song = JSON.parse(JSON.stringify(songToCopy));
  1054. let saveButtonRef = this.$refs.saveButton;
  1055. if (close && !verify) saveButtonRef = this.$refs.saveAndCloseButton;
  1056. else if (close && verify)
  1057. saveButtonRef = this.$refs.saveVerifyAndCloseButton;
  1058. if (!this.youtubeError && this.youtubeVideoDuration === "0.000") {
  1059. saveButtonRef.handleFailedSave();
  1060. return new Toast("The video appears to not be working.");
  1061. }
  1062. if (!song.title) {
  1063. saveButtonRef.handleFailedSave();
  1064. return new Toast("Please fill in all fields");
  1065. }
  1066. if (!song.thumbnail) {
  1067. saveButtonRef.handleFailedSave();
  1068. return new Toast("Please fill in all fields");
  1069. }
  1070. // const thumbnailHeight = this.$refs.thumbnailElement.naturalHeight;
  1071. // const thumbnailWidth = this.$refs.thumbnailElement.naturalWidth;
  1072. // if (thumbnailHeight < 80 || thumbnailWidth < 80) {
  1073. // saveButtonRef.handleFailedSave();
  1074. // return new Toast(
  1075. // "Thumbnail width and height must be at least 80px."
  1076. // );
  1077. // }
  1078. // if (thumbnailHeight > 4000 || thumbnailWidth > 4000) {
  1079. // saveButtonRef.handleFailedSave();
  1080. // return new Toast(
  1081. // "Thumbnail width and height must be less than 4000px."
  1082. // );
  1083. // }
  1084. // if (thumbnailHeight - thumbnailWidth > 5) {
  1085. // saveButtonRef.handleFailedSave();
  1086. // return new Toast("Thumbnail cannot be taller than it is wide.");
  1087. // }
  1088. // Youtube Id
  1089. if (
  1090. this.youtubeError &&
  1091. this.originalSong.youtubeId !== song.youtubeId
  1092. ) {
  1093. saveButtonRef.handleFailedSave();
  1094. return new Toast(
  1095. "You're not allowed to change the YouTube id while the player is not working"
  1096. );
  1097. }
  1098. // Duration
  1099. if (
  1100. Number(song.skipDuration) + Number(song.duration) >
  1101. this.youtubeVideoDuration &&
  1102. (!this.youtubeError ||
  1103. this.originalSong.duration !== song.duration)
  1104. ) {
  1105. saveButtonRef.handleFailedSave();
  1106. return new Toast(
  1107. "Duration can't be higher than the length of the video"
  1108. );
  1109. }
  1110. // Title
  1111. if (!validation.isLength(song.title, 1, 100)) {
  1112. saveButtonRef.handleFailedSave();
  1113. return new Toast(
  1114. "Title must have between 1 and 100 characters."
  1115. );
  1116. }
  1117. // Artists
  1118. if (song.artists.length < 1 || song.artists.length > 10) {
  1119. saveButtonRef.handleFailedSave();
  1120. return new Toast(
  1121. "Invalid artists. You must have at least 1 artist and a maximum of 10 artists."
  1122. );
  1123. }
  1124. let error;
  1125. song.artists.forEach(artist => {
  1126. if (!validation.isLength(artist, 1, 64)) {
  1127. error = "Artist must have between 1 and 64 characters.";
  1128. return error;
  1129. }
  1130. if (artist === "NONE") {
  1131. error =
  1132. 'Invalid artist format. Artists are not allowed to be named "NONE".';
  1133. return error;
  1134. }
  1135. return false;
  1136. });
  1137. if (error) {
  1138. saveButtonRef.handleFailedSave();
  1139. return new Toast(error);
  1140. }
  1141. // Genres
  1142. error = undefined;
  1143. song.genres.forEach(genre => {
  1144. if (!validation.isLength(genre, 1, 32)) {
  1145. error = "Genre must have between 1 and 32 characters.";
  1146. return error;
  1147. }
  1148. if (!validation.regex.ascii.test(genre)) {
  1149. error =
  1150. "Invalid genre format. Only ascii characters are allowed.";
  1151. return error;
  1152. }
  1153. return false;
  1154. });
  1155. if (song.genres.length < 1 || song.genres.length > 16)
  1156. error = "You must have between 1 and 16 genres.";
  1157. if (error) {
  1158. saveButtonRef.handleFailedSave();
  1159. return new Toast(error);
  1160. }
  1161. // Thumbnail
  1162. if (!validation.isLength(song.thumbnail, 1, 256)) {
  1163. saveButtonRef.handleFailedSave();
  1164. return new Toast(
  1165. "Thumbnail must have between 8 and 256 characters."
  1166. );
  1167. }
  1168. if (this.useHTTPS && song.thumbnail.indexOf("https://") !== 0) {
  1169. saveButtonRef.handleFailedSave();
  1170. return new Toast('Thumbnail must start with "https://".');
  1171. }
  1172. if (
  1173. !this.useHTTPS &&
  1174. song.thumbnail.indexOf("http://") !== 0 &&
  1175. song.thumbnail.indexOf("https://") !== 0
  1176. ) {
  1177. saveButtonRef.handleFailedSave();
  1178. return new Toast('Thumbnail must start with "http://".');
  1179. }
  1180. saveButtonRef.status = "disabled";
  1181. return this.socket.dispatch(`songs.update`, song._id, song, res => {
  1182. new Toast(res.message);
  1183. if (res.status === "success")
  1184. saveButtonRef.handleSuccessfulSave();
  1185. else saveButtonRef.handleFailedSave();
  1186. if (verify) this.verify(this.song._id);
  1187. if (close) this.closeModal("editSong");
  1188. });
  1189. },
  1190. getAlbumData(type) {
  1191. if (!this.song.discogs) return;
  1192. if (type === "title")
  1193. this.updateSongField({
  1194. field: "title",
  1195. value: this.song.discogs.track.title
  1196. });
  1197. if (type === "albumArt")
  1198. this.updateSongField({
  1199. field: "thumbnail",
  1200. value: this.song.discogs.album.albumArt
  1201. });
  1202. if (type === "genres")
  1203. this.updateSongField({
  1204. field: "genres",
  1205. value: JSON.parse(
  1206. JSON.stringify(this.song.discogs.album.genres)
  1207. )
  1208. });
  1209. if (type === "artists")
  1210. this.updateSongField({
  1211. field: "artists",
  1212. value: JSON.parse(
  1213. JSON.stringify(this.song.discogs.album.artists)
  1214. )
  1215. });
  1216. },
  1217. fillDuration() {
  1218. this.song.duration =
  1219. this.youtubeVideoDuration - this.song.skipDuration;
  1220. },
  1221. blurArtistInput() {
  1222. this.artistInputFocussed = false;
  1223. },
  1224. focusArtistInput() {
  1225. this.artistInputFocussed = true;
  1226. },
  1227. blurArtistContainer() {
  1228. this.artistAutosuggestContainerFocussed = false;
  1229. },
  1230. focusArtistContainer() {
  1231. this.artistAutosuggestContainerFocussed = true;
  1232. },
  1233. keydownArtistInput() {
  1234. clearTimeout(this.keydownArtistInputTimeout);
  1235. this.keydownArtistInputTimeout = setTimeout(() => {
  1236. // Do things here to query the artist
  1237. }, 1000);
  1238. },
  1239. blurGenreInput() {
  1240. this.genreInputFocussed = false;
  1241. },
  1242. focusGenreInput() {
  1243. this.genreInputFocussed = true;
  1244. },
  1245. blurGenreContainer() {
  1246. this.genreAutosuggestContainerFocussed = false;
  1247. },
  1248. focusGenreContainer() {
  1249. this.genreAutosuggestContainerFocussed = true;
  1250. },
  1251. keydownGenreInput() {
  1252. clearTimeout(this.keydownGenreInputTimeout);
  1253. this.keydownGenreInputTimeout = setTimeout(() => {
  1254. if (this.genreInputValue.length > 1) {
  1255. this.genreAutosuggestItems = this.genres.filter(genre =>
  1256. genre
  1257. .toLowerCase()
  1258. .startsWith(this.genreInputValue.toLowerCase())
  1259. );
  1260. } else this.genreAutosuggestItems = [];
  1261. }, 1000);
  1262. },
  1263. settings(type) {
  1264. switch (type) {
  1265. default:
  1266. break;
  1267. case "stop":
  1268. this.stopVideo();
  1269. this.pauseVideo(true);
  1270. break;
  1271. case "pause":
  1272. this.pauseVideo(true);
  1273. break;
  1274. case "play":
  1275. this.pauseVideo(false);
  1276. break;
  1277. case "skipToLast10Secs":
  1278. this.skipToLast10SecsPressed = true;
  1279. if (this.video.paused) this.pauseVideo(false);
  1280. this.video.player.seekTo(
  1281. this.song.duration - 10 + this.song.skipDuration
  1282. );
  1283. break;
  1284. }
  1285. },
  1286. play() {
  1287. if (
  1288. this.video.player.getVideoData().video_id !==
  1289. this.song.youtubeId
  1290. ) {
  1291. this.song.duration = -1;
  1292. this.loadVideoById(this.song.youtubeId, this.song.skipDuration);
  1293. }
  1294. this.settings("play");
  1295. },
  1296. changeVolume() {
  1297. const volume = this.volumeSliderValue;
  1298. localStorage.setItem("volume", volume / 100);
  1299. this.video.player.setVolume(volume / 100);
  1300. if (volume > 0) {
  1301. this.video.player.unMute();
  1302. this.muted = false;
  1303. }
  1304. },
  1305. toggleMute() {
  1306. const previousVolume = parseFloat(localStorage.getItem("volume"));
  1307. const volume =
  1308. this.video.player.getVolume() * 100 <= 0 ? previousVolume : 0;
  1309. this.muted = !this.muted;
  1310. this.volumeSliderValue = volume * 100;
  1311. this.video.player.setVolume(volume);
  1312. if (!this.muted) localStorage.setItem("volume", volume);
  1313. },
  1314. increaseVolume() {
  1315. const previousVolume = parseInt(localStorage.getItem("volume"));
  1316. let volume = previousVolume + 5;
  1317. this.muted = false;
  1318. if (volume > 100) volume = 100;
  1319. this.volumeSliderValue = volume * 100;
  1320. this.video.player.setVolume(volume);
  1321. localStorage.setItem("volume", volume);
  1322. },
  1323. addTag(type, value) {
  1324. if (type === "genres") {
  1325. const genre = value || this.genreInputValue.trim();
  1326. if (
  1327. this.song.genres
  1328. .map(genre => genre.toLowerCase())
  1329. .indexOf(genre.toLowerCase()) !== -1
  1330. )
  1331. return new Toast("Genre already exists");
  1332. if (genre) {
  1333. this.song.genres.push(genre);
  1334. this.genreInputValue = "";
  1335. this.genreAutosuggestItems = [];
  1336. return false;
  1337. }
  1338. return new Toast("Genre cannot be empty");
  1339. }
  1340. if (type === "artists") {
  1341. const artist = value || this.artistInputValue;
  1342. if (this.song.artists.indexOf(artist) !== -1)
  1343. return new Toast("Artist already exists");
  1344. if (artist !== "") {
  1345. this.song.artists.push(artist);
  1346. this.artistInputValue = "";
  1347. this.artistAutosuggestItems = [];
  1348. return false;
  1349. }
  1350. return new Toast("Artist cannot be empty");
  1351. }
  1352. return false;
  1353. },
  1354. removeTag(type, value) {
  1355. if (type === "genres")
  1356. this.song.genres.splice(this.song.genres.indexOf(value), 1);
  1357. else if (type === "artists")
  1358. this.song.artists.splice(this.song.artists.indexOf(value), 1);
  1359. },
  1360. drawCanvas() {
  1361. const canvasElement = this.$refs.durationCanvas;
  1362. const ctx = canvasElement.getContext("2d");
  1363. const videoDuration = Number(this.youtubeVideoDuration);
  1364. const skipDuration = Number(this.song.skipDuration);
  1365. const duration = Number(this.song.duration);
  1366. const afterDuration = videoDuration - (skipDuration + duration);
  1367. const width = 530;
  1368. const currentTime =
  1369. this.video.player && this.video.player.getCurrentTime
  1370. ? this.video.player.getCurrentTime()
  1371. : 0;
  1372. const widthSkipDuration = (skipDuration / videoDuration) * width;
  1373. const widthDuration = (duration / videoDuration) * width;
  1374. const widthAfterDuration = (afterDuration / videoDuration) * width;
  1375. const widthCurrentTime = (currentTime / videoDuration) * width;
  1376. const skipDurationColor = "#F42003";
  1377. const durationColor = "#03A9F4";
  1378. const afterDurationColor = "#41E841";
  1379. const currentDurationColor = "#3b25e8";
  1380. ctx.fillStyle = skipDurationColor;
  1381. ctx.fillRect(0, 0, widthSkipDuration, 20);
  1382. ctx.fillStyle = durationColor;
  1383. ctx.fillRect(widthSkipDuration, 0, widthDuration, 20);
  1384. ctx.fillStyle = afterDurationColor;
  1385. ctx.fillRect(
  1386. widthSkipDuration + widthDuration,
  1387. 0,
  1388. widthAfterDuration,
  1389. 20
  1390. );
  1391. ctx.fillStyle = currentDurationColor;
  1392. ctx.fillRect(widthCurrentTime, 0, 1, 20);
  1393. },
  1394. toggleGenreHelper() {
  1395. this.$refs.genreHelper.toggleBox();
  1396. },
  1397. resetGenreHelper() {
  1398. this.$refs.genreHelper.resetBox();
  1399. },
  1400. sendActivityWatchVideoData() {
  1401. if (!this.video.paused) {
  1402. if (this.activityWatchVideoLastStatus !== "playing") {
  1403. this.activityWatchVideoLastStatus = "playing";
  1404. if (
  1405. this.song.skipDuration > 0 &&
  1406. parseFloat(this.youtubeVideoCurrentTime) === 0
  1407. ) {
  1408. this.activityWatchVideoLastStartDuration = Math.floor(
  1409. this.song.skipDuration +
  1410. parseFloat(this.youtubeVideoCurrentTime)
  1411. );
  1412. } else {
  1413. this.activityWatchVideoLastStartDuration = Math.floor(
  1414. parseFloat(this.youtubeVideoCurrentTime)
  1415. );
  1416. }
  1417. }
  1418. const videoData = {
  1419. title: this.song.title,
  1420. artists: this.song.artists
  1421. ? this.song.artists.join(", ")
  1422. : null,
  1423. youtubeId: this.song.youtubeId,
  1424. muted: this.muted,
  1425. volume: this.volumeSliderValue / 100,
  1426. startedDuration:
  1427. this.activityWatchVideoLastStartDuration <= 0
  1428. ? 0
  1429. : this.activityWatchVideoLastStartDuration,
  1430. source: `editSong#${this.song.youtubeId}`,
  1431. hostname: window.location.hostname
  1432. };
  1433. aw.sendVideoData(videoData);
  1434. } else {
  1435. this.activityWatchVideoLastStatus = "not_playing";
  1436. }
  1437. },
  1438. verify(id) {
  1439. this.socket.dispatch("songs.verify", id, res => {
  1440. new Toast(res.message);
  1441. });
  1442. },
  1443. unverify(id) {
  1444. this.socket.dispatch("songs.unverify", id, res => {
  1445. new Toast(res.message);
  1446. });
  1447. },
  1448. hide(id) {
  1449. this.socket.dispatch("songs.hide", id, res => {
  1450. new Toast(res.message);
  1451. });
  1452. },
  1453. unhide(id) {
  1454. this.socket.dispatch("songs.unhide", id, res => {
  1455. new Toast(res.message);
  1456. });
  1457. },
  1458. // remove(id) {
  1459. // this.socket.dispatch("songs.remove", id, res => {
  1460. // new Toast(res.message);
  1461. // });
  1462. // },
  1463. ...mapActions("modals/importAlbum", [
  1464. "selectDiscogsAlbum",
  1465. "updateEditingSongs"
  1466. ]),
  1467. ...mapActions({
  1468. showTab(dispatch, payload) {
  1469. this.$refs[`${payload}-tab`].scrollIntoView({
  1470. block: "nearest"
  1471. });
  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. margin: 0 5px;
  1638. img {
  1639. height: 21px;
  1640. margin-right: 12px;
  1641. filter: invert(26%) sepia(54%) saturate(6317%)
  1642. hue-rotate(2deg) brightness(92%) contrast(115%);
  1643. }
  1644. }
  1645. .player-footer-right {
  1646. justify-content: right;
  1647. flex: 1;
  1648. #volume-control {
  1649. margin: 3px;
  1650. margin-top: 0;
  1651. display: flex;
  1652. align-items: center;
  1653. cursor: pointer;
  1654. .volume-slider {
  1655. width: 100%;
  1656. padding: 0 15px;
  1657. background: transparent;
  1658. min-width: 100px;
  1659. }
  1660. input[type="range"] {
  1661. -webkit-appearance: none;
  1662. margin: 7.3px 0;
  1663. }
  1664. input[type="range"]:focus {
  1665. outline: none;
  1666. }
  1667. input[type="range"]::-webkit-slider-runnable-track {
  1668. width: 100%;
  1669. height: 5.2px;
  1670. cursor: pointer;
  1671. box-shadow: 0;
  1672. background: var(--light-grey-3);
  1673. border-radius: 0;
  1674. border: 0;
  1675. }
  1676. input[type="range"]::-webkit-slider-thumb {
  1677. box-shadow: 0;
  1678. border: 0;
  1679. height: 19px;
  1680. width: 19px;
  1681. border-radius: 15px;
  1682. background: var(--primary-color);
  1683. cursor: pointer;
  1684. -webkit-appearance: none;
  1685. margin-top: -6.5px;
  1686. }
  1687. input[type="range"]::-moz-range-track {
  1688. width: 100%;
  1689. height: 5.2px;
  1690. cursor: pointer;
  1691. box-shadow: 0;
  1692. background: var(--light-grey-3);
  1693. border-radius: 0;
  1694. border: 0;
  1695. }
  1696. input[type="range"]::-moz-range-thumb {
  1697. box-shadow: 0;
  1698. border: 0;
  1699. height: 19px;
  1700. width: 19px;
  1701. border-radius: 15px;
  1702. background: var(--primary-color);
  1703. cursor: pointer;
  1704. -webkit-appearance: none;
  1705. margin-top: -6.5px;
  1706. }
  1707. input[type="range"]::-ms-track {
  1708. width: 100%;
  1709. height: 5.2px;
  1710. cursor: pointer;
  1711. box-shadow: 0;
  1712. background: var(--light-grey-3);
  1713. border-radius: 1.3px;
  1714. }
  1715. input[type="range"]::-ms-fill-lower {
  1716. background: var(--light-grey-3);
  1717. border: 0;
  1718. border-radius: 0;
  1719. box-shadow: 0;
  1720. }
  1721. input[type="range"]::-ms-fill-upper {
  1722. background: var(--light-grey-3);
  1723. border: 0;
  1724. border-radius: 0;
  1725. box-shadow: 0;
  1726. }
  1727. input[type="range"]::-ms-thumb {
  1728. box-shadow: 0;
  1729. border: 0;
  1730. height: 15px;
  1731. width: 15px;
  1732. border-radius: 15px;
  1733. background: var(--primary-color);
  1734. cursor: pointer;
  1735. -webkit-appearance: none;
  1736. margin-top: 1.5px;
  1737. }
  1738. }
  1739. }
  1740. }
  1741. }
  1742. }
  1743. .edit-section {
  1744. border: 1px solid var(--light-grey-3);
  1745. margin-top: 16px;
  1746. border-radius: 3px;
  1747. .album-get-button {
  1748. background-color: var(--purple);
  1749. color: var(--white);
  1750. width: 32px;
  1751. text-align: center;
  1752. border-width: 0;
  1753. }
  1754. .duration-fill-button {
  1755. background-color: var(--red);
  1756. color: var(--white);
  1757. width: 32px;
  1758. text-align: center;
  1759. border-width: 0;
  1760. }
  1761. .add-button {
  1762. background-color: var(--primary-color) !important;
  1763. width: 32px;
  1764. i {
  1765. font-size: 32px;
  1766. }
  1767. }
  1768. .album-get-button,
  1769. .duration-fill-button,
  1770. .add-button {
  1771. &:focus,
  1772. &:hover {
  1773. filter: contrast(0.75);
  1774. border: 1px solid var(--black) !important;
  1775. }
  1776. }
  1777. > div {
  1778. margin: 16px !important;
  1779. }
  1780. input {
  1781. width: 100%;
  1782. }
  1783. .title-container {
  1784. width: calc((100% - 32px) / 2);
  1785. }
  1786. .duration-container {
  1787. margin-right: 16px;
  1788. margin-left: 16px;
  1789. width: calc((100% - 32px) / 4);
  1790. }
  1791. .skip-duration-container {
  1792. width: calc((100% - 32px) / 4);
  1793. }
  1794. .album-art-container {
  1795. display: flex;
  1796. flex-direction: column;
  1797. div {
  1798. display: flex;
  1799. flex-direction: row;
  1800. align-items: center;
  1801. .thumbnail-preview {
  1802. border: 1px solid var(--light-grey-3);
  1803. width: 75px;
  1804. height: 75px;
  1805. }
  1806. .control {
  1807. margin-left: 20px;
  1808. width: 100%;
  1809. }
  1810. }
  1811. }
  1812. .artists-container {
  1813. width: calc((100% - 32px) / 3);
  1814. position: relative;
  1815. }
  1816. .genres-container {
  1817. width: calc((100% - 32px) / 3);
  1818. margin-left: 16px;
  1819. margin-right: 16px;
  1820. position: relative;
  1821. label {
  1822. display: flex;
  1823. i {
  1824. font-size: 15px;
  1825. align-self: center;
  1826. margin-left: 5px;
  1827. color: var(--primary-color);
  1828. cursor: pointer;
  1829. -webkit-user-select: none;
  1830. -moz-user-select: none;
  1831. -ms-user-select: none;
  1832. user-select: none;
  1833. }
  1834. }
  1835. }
  1836. .youtube-id-container {
  1837. width: calc((100% - 32px) / 3);
  1838. }
  1839. .list-item-circle {
  1840. background-color: var(--primary-color);
  1841. width: 16px;
  1842. height: 16px;
  1843. border-radius: 8px;
  1844. cursor: pointer;
  1845. margin-right: 8px;
  1846. float: left;
  1847. -webkit-touch-callout: none;
  1848. -webkit-user-select: none;
  1849. -khtml-user-select: none;
  1850. -moz-user-select: none;
  1851. -ms-user-select: none;
  1852. user-select: none;
  1853. i {
  1854. color: var(--primary-color);
  1855. font-size: 14px;
  1856. margin-left: 1px;
  1857. position: relative;
  1858. top: -1px;
  1859. }
  1860. }
  1861. .list-item-circle:hover,
  1862. .list-item-circle:focus {
  1863. i {
  1864. color: var(--white);
  1865. }
  1866. }
  1867. .list-item > p {
  1868. line-height: 16px;
  1869. word-wrap: break-word;
  1870. width: calc(100% - 24px);
  1871. left: 24px;
  1872. float: left;
  1873. margin-bottom: 8px;
  1874. }
  1875. .list-item:last-child > p {
  1876. margin-bottom: 0;
  1877. }
  1878. .autosuggest-container {
  1879. position: absolute;
  1880. background: var(--white);
  1881. width: calc(100% + 1px);
  1882. top: 57px;
  1883. z-index: 200;
  1884. overflow: auto;
  1885. max-height: 100%;
  1886. clear: both;
  1887. .autosuggest-item {
  1888. padding: 8px;
  1889. display: block;
  1890. border: 1px solid var(--light-grey-2);
  1891. margin-top: -1px;
  1892. line-height: 16px;
  1893. cursor: pointer;
  1894. -webkit-user-select: none;
  1895. -ms-user-select: none;
  1896. -moz-user-select: none;
  1897. user-select: none;
  1898. }
  1899. .autosuggest-item:hover,
  1900. .autosuggest-item:focus {
  1901. background-color: var(--light-grey);
  1902. }
  1903. .autosuggest-item:first-child {
  1904. border-top: none;
  1905. }
  1906. .autosuggest-item:last-child {
  1907. border-radius: 0 0 3px 3px;
  1908. }
  1909. }
  1910. }
  1911. }
  1912. .right-section {
  1913. display: flex;
  1914. flex-wrap: wrap;
  1915. flex-basis: 450px;
  1916. overflow-y: auto;
  1917. @media screen and (max-width: 1245px) {
  1918. height: inherit !important;
  1919. }
  1920. #tabs-container {
  1921. overflow: auto;
  1922. display: flex;
  1923. flex-direction: column;
  1924. flex-grow: 1;
  1925. #tab-selection {
  1926. display: flex;
  1927. overflow-x: auto;
  1928. .button {
  1929. border-radius: 5px 5px 0 0;
  1930. border: 0;
  1931. text-transform: uppercase;
  1932. font-size: 14px;
  1933. color: var(--dark-grey-3);
  1934. background-color: var(--light-grey-2);
  1935. flex-grow: 1;
  1936. height: 32px;
  1937. &:not(:first-of-type) {
  1938. margin-left: 5px;
  1939. }
  1940. }
  1941. .selected {
  1942. background-color: var(--primary-color) !important;
  1943. color: var(--white) !important;
  1944. font-weight: 600;
  1945. }
  1946. }
  1947. .tab {
  1948. border: 1px solid var(--light-grey-3);
  1949. border-radius: 3px;
  1950. padding: 15px;
  1951. }
  1952. }
  1953. // .api-section {
  1954. // width: 376px;
  1955. // background-color: var(--light-grey);
  1956. // border: 1px rgba(163, 224, 255, 0.75) solid;
  1957. // border-radius: 5px;
  1958. // padding: 16px;
  1959. // overflow: auto;
  1960. // height: 100%;
  1961. // > label {
  1962. // margin-top: 12px;
  1963. // }
  1964. // .top-container {
  1965. // display: flex;
  1966. // img {
  1967. // height: 85px;
  1968. // width: 85px;
  1969. // }
  1970. // .right-container {
  1971. // padding: 8px;
  1972. // display: flex;
  1973. // flex-direction: column;
  1974. // flex: 1;
  1975. // .album-title {
  1976. // flex: 1;
  1977. // font-weight: 600;
  1978. // }
  1979. // .bottom-row {
  1980. // display: flex;
  1981. // flex-flow: row;
  1982. // line-height: 15px;
  1983. // img {
  1984. // height: 15px;
  1985. // align-self: end;
  1986. // flex: 1;
  1987. // user-select: none;
  1988. // -moz-user-select: none;
  1989. // -ms-user-select: none;
  1990. // -webkit-user-select: none;
  1991. // cursor: pointer;
  1992. // }
  1993. // p {
  1994. // text-align: right;
  1995. // }
  1996. // .type-year {
  1997. // font-size: 13px;
  1998. // align-self: end;
  1999. // }
  2000. // }
  2001. // }
  2002. // }
  2003. // .bottom-container {
  2004. // padding: 12px;
  2005. // .bottom-container-field {
  2006. // line-height: 16px;
  2007. // margin-bottom: 8px;
  2008. // font-weight: 600;
  2009. // span {
  2010. // font-weight: 400;
  2011. // }
  2012. // }
  2013. // .bottom-container-field:last-of-type {
  2014. // margin-bottom: 0;
  2015. // }
  2016. // }
  2017. // .selected-discogs-info {
  2018. // background-color: var(--white);
  2019. // border: 1px solid var(--purple);
  2020. // border-radius: 5px;
  2021. // margin-bottom: 16px;
  2022. // .selected-discogs-info-none {
  2023. // font-size: 18px;
  2024. // text-align: center;
  2025. // }
  2026. // .bottom-row > p {
  2027. // flex: 1;
  2028. // }
  2029. // }
  2030. // .api-result {
  2031. // background-color: var(--white);
  2032. // border: 0.5px solid var(--primary-color);
  2033. // border-radius: 5px;
  2034. // margin-bottom: 16px;
  2035. // }
  2036. // button {
  2037. // background-color: var(--primary-color) !important;
  2038. // &:focus,
  2039. // &:hover {
  2040. // filter: contrast(0.75);
  2041. // }
  2042. // }
  2043. // .tracks {
  2044. // margin-top: 12px;
  2045. // .track:first-child {
  2046. // margin-top: 0;
  2047. // border-radius: 3px 3px 0 0;
  2048. // }
  2049. // .track:last-child {
  2050. // border-radius: 0 0 3px 3px;
  2051. // }
  2052. // .track {
  2053. // border: 0.5px solid var(--black);
  2054. // margin-top: -1px;
  2055. // line-height: 16px;
  2056. // display: flex;
  2057. // cursor: pointer;
  2058. // span {
  2059. // font-weight: 600;
  2060. // display: inline-block;
  2061. // margin-top: 7px;
  2062. // margin-bottom: 7px;
  2063. // margin-left: 7px;
  2064. // }
  2065. // p {
  2066. // display: inline-block;
  2067. // margin: 7px;
  2068. // flex: 1;
  2069. // }
  2070. // }
  2071. // .track:hover,
  2072. // .track:focus {
  2073. // background-color: var(--light-grey);
  2074. // }
  2075. // }
  2076. // .discogs-load-more {
  2077. // margin-bottom: 8px;
  2078. // }
  2079. // }
  2080. }
  2081. .modal-card-foot .is-primary {
  2082. width: 200px;
  2083. }
  2084. </style>