|
2 | 2 | // @ts-nocheck |
3 | 3 |
|
4 | 4 | import fecthYT from "../utils/fetchYT"; |
| 5 | + import { bgImage } from "../utils/store"; |
| 6 | + let player = $state(null); |
| 7 | + let isPlaying = $state(false); |
5 | 8 |
|
6 | | - let url = $state(""); |
| 9 | + let text = $state(""); |
7 | 10 | let data = $state(null); |
8 | | -
|
| 11 | + // data = { |
| 12 | + // title: "Playlist Speed up | Những bản nhạc hot của Dangrangto", |
| 13 | + // author: "Whojsdat", |
| 14 | + // thumbnail: "https://i.ytimg.com/vi/i0zmZ8CJetQ/maxresdefault.jpg", |
| 15 | + // mp3Url: |
| 16 | + // "https://rr4---sn-8pxuuxa-nbo6r.googlevideo.com/videoplayback?expire=1741967115&ei=q_rTZ8f3LbSX1d8P4oLrsQU&ip=115.73.223.143&id=o-AKDWtmn4k6m4dntUrnwrhTvAVDa0XPc9CJ0O-YMGFEcZ&itag=18&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&met=1741945515%2C&mh=VG&mm=31%2C26&mn=sn-8pxuuxa-nbo6r%2Csn-oguelnl7&ms=au%2Conr&mv=m&mvi=4&pl=22&rms=au%2Cau&initcwndbps=2248750&bui=AccgBcMEqdOGlyW3Yaa3yKV8jD3z0qlsSAlntsLwGtvyE7ZQaHLStYRj_czS1wzOhbCXNFeXg2HExb_j&vprv=1&svpuc=1&mime=video%2Fmp4&ns=Fd28Zgp-gGgosIof9abGQa8Q&rqh=1&gir=yes&clen=25127877&ratebypass=yes&dur=1192.623&lmt=1738369982799696&mt=1741945021&fvip=5&lmw=1&fexp=51358317%2C51411872&c=TVHTML5&sefc=1&txp=5438534&n=K3vxmBS1AolHSA&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&lsparams=met%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Crms%2Cinitcwndbps&lsig=AFVRHeAwRgIhAN1QdJ1stbZADO5nFTFoK2SCBsMaAFaIhKoQzI3dmgE0AiEAn9fvPDZ5FzOW8qCB8iT22FTcJSRVbUTGPTuB90rgIuM%3D&sig=AJfQdSswRQIgK-HwRxxQ9D6_rATI6ngJFEnlbjjgH4C6ZKPFPpLK0rgCIQDuN9IOx8vg3BilSi7d0qF5CVMIlV3AAUShUMQWm-bNNw%3D%3D", |
| 17 | + // }; |
9 | 18 | // @ts-ignore |
10 | 19 | const fetch = async (e) => { |
11 | 20 | e.preventDefault(); |
12 | 21 | const link = e.target[0].value; |
13 | 22 | data = await fecthYT(link); |
| 23 | + bgImage.set(data.thumbnail); |
14 | 24 | console.log(data); |
15 | 25 | }; |
| 26 | +
|
| 27 | + function updateData() { |
| 28 | + sharedData.set("Dữ liệu từ con"); |
| 29 | + } |
16 | 30 | </script> |
17 | 31 |
|
18 | 32 | <div class="w-full h-full bg-white/80 rounded-lg"> |
19 | 33 | {#if data} |
20 | | - <div class="flex flex-row gap-2 items-center justify-center h-full"> |
21 | | - <img |
22 | | - class="max-h-full h-full rounded-lg" |
23 | | - src={data.thumbnail} |
24 | | - alt={data.title} |
25 | | - /> |
| 34 | + <div |
| 35 | + class="flex flex-row gap-2 max-h-full items-center justify-center h-full overflow-hidden" |
| 36 | + > |
| 37 | + <audio |
| 38 | + onpause={() => (isPlaying = false)} |
| 39 | + onplaying={() => (isPlaying = true)} |
| 40 | + bind:this={player} |
| 41 | + src={data.mp3Url} |
| 42 | + loop |
| 43 | + ></audio> |
| 44 | + <button |
| 45 | + class="max-h-full p-2 rounded-xl overflow-hidden" |
| 46 | + onclick={() => (isPlaying ? player?.pause() : player?.play())} |
| 47 | + > |
| 48 | + <img |
| 49 | + class="h-full hover:opacity-80" |
| 50 | + src={data.thumbnail} |
| 51 | + alt={data.title} |
| 52 | + /> |
| 53 | + </button> |
| 54 | + <div class="h-full flex flex-col gap-2 pr-1 justify-around"> |
| 55 | + <p class="xl:text-lg text-md font-medium">{data.title}</p> |
| 56 | + <p class="text-sm">{data.author}</p> |
| 57 | + </div> |
26 | 58 | </div> |
27 | 59 | {:else} |
28 | 60 | <form |
29 | 61 | onsubmit={fetch} |
30 | 62 | class="flex flex-col gap-2 items-center justify-center h-full py-4 px-8" |
31 | 63 | > |
32 | 64 | <input |
33 | | - bind:value={url} |
| 65 | + bind:value={text} |
34 | 66 | type="text" |
35 | 67 | placeholder="Nhập link" |
36 | 68 | class="w-full h-full rounded-lg p-2 border border-gray-200 outline-none outline-white/80" |
|
0 commit comments