Тёмный

Custom HTML5 Video Player -  

Wes Bos
Подписаться 191 тыс.
Просмотров 120 тыс.
50% 1

Today we build a custom HTML5 video player interface with HTML, CSS and JavaScript. Grab all the exercises and starter files over at JavaScript30.com

Опубликовано:

 

21 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 108   
@macos-brasil1814
@macos-brasil1814 6 лет назад
"Progress" is used to get the buffer data from the video. Is usefull to create some preloader buffer bar to you know how much video your browser is already downloaded.
@quentinmckay8658
@quentinmckay8658 6 лет назад
@ 14:16 listening for the the 'input' event on the sliders seems like a cleaner solution than 2 listeners and a flag. Thanks for the amazing tutorial !
@FarhanShaikh-sz5ww
@FarhanShaikh-sz5ww 2 года назад
For Full Screen : ⛶ (Edit in HTML) (And in JS File) function openFullscreen() { if (video.requestFullscreen) { video.requestFullscreen(); } }
@advaitgogte6385
@advaitgogte6385 Год назад
Thank you so much
@woung717
@woung717 4 года назад
What a heartwarming story. You should watch it before the next chapter!
@AnhMinh-rj4bj
@AnhMinh-rj4bj 3 года назад
4:23 - Build function for toggle play 6:03 - Hook up the event listeners I will be back to update my study I just mark the main point. Hope you feel comfortable with this
@Martiesim
@Martiesim 5 лет назад
Hi, great video! The progress event is fired when the progress of downloading the media from the server changes, not when the current time of the video playback changes.
@_STF2023_the_camera.kinemaster
@_STF2023_the_camera.kinemaster 4 года назад
thanks man.. Greetings from Brazil.
@erikhendin3459
@erikhendin3459 Год назад
This is super cool - Thanks Wes! Bug fix I needed was to add one more event listener for mouseleave: progress.addEventListener('mouseleave', () => isMouseDown = false); Explanation/Scenario: User clicks and drags progress bar. User moves mouse off of/outside of the progress bar. Result: the mousedown stays true and video scrubbing when my mouse went back over progress bar. However, this is not desired from my perspective. The mouseleave event essentially acts like mouseup in this case, so when user has clicked and dragged and accidentally moves off of progress bar before mousing up, this line of code it will set mousedown to false. In my case I renamed the variable mousedown to isMouseDown so I did not confuse the mousedown event with the boolean variable isMouseDown.
@EugeneVe
@EugeneVe 2 года назад
Its all great but how to be with a fullscreen?
@SherazManzoor-p7s
@SherazManzoor-p7s Год назад
Thanks man for teaching us. Well where is the solved version?
@dingjoyce5500
@dingjoyce5500 Год назад
At 15:24, I don' t understand why this.name = this.value; string = float?
@WesBos
@WesBos Год назад
.value is awlays a string. Use .valueAsNumber if you want it as a float
@LucasMeadows
@LucasMeadows 5 лет назад
😂 don't send me angry mail, just don't use it.
@timifalode5152
@timifalode5152 2 года назад
That shit fucked me up
@VedanttMehtaa
@VedanttMehtaa 4 года назад
How to store current time in local storage so that if i closed the window and Restart it i play back from the same time???
@zoomerpanda3215
@zoomerpanda3215 3 года назад
17:10 sorry, what are those characters around the percent variable? they look like {} but when I put that in I get a console error. nevermind I didnt write function before handleProgress. kill me
@elchinhuseynli8876
@elchinhuseynli8876 3 года назад
Nice one. However, when you have more than one video on a page it works only for the first one you click, because everything is tide up to classes. Is there any way to fix it without adding manually id's or sub-classes?
@basantakc2168
@basantakc2168 5 лет назад
How can we put direct icon on html?? Anyone without font-awesome . Like wes did for pause and play
@chabinot2274
@chabinot2274 2 года назад
Hello, skip and handle RangeUpdate functions give me an undefined value.
@sondosabd9474
@sondosabd9474 5 лет назад
How can i get the pause and the play icon????????
@poornachandraparlapalli4359
@poornachandraparlapalli4359 6 месяцев назад
hi Wes, We want .css and .js files used in this procedure
@tonyi2430
@tonyi2430 5 лет назад
Okay so I've been trying to replicate the scrub found at 15:42 for an audio player, and despite copying the code to a t, it doesn't work at all. When setting my audio.currentTime = scrubTime, the audio.currentTime sets itself to 0 regardless of what scrubTime is, and the song restarts again. I've tried everything but I have absolutely no idea.
@danbuild977
@danbuild977 6 лет назад
I managed to find a little bug with this one. How can I limit the if statement to only fire after the second mouse click? - I find if I select the first Tickbox with shift held down, then all the checkboxes are selected. This related to Shift and Select Tutorial video.
@VivekGawande1
@VivekGawande1 6 лет назад
Same even I found that bug
@silvrsurfer
@silvrsurfer 2 года назад
Can you make a tutorial for html 5 video with event listeners for it to: - pause when not on screen and play when on screen. -autoplay -loop -mute -hide absolutely all controls - video player has softer/rounder corners with border radius ... Is this possible?
@KumataZabka
@KumataZabka 2 года назад
Solution for full screen homework HTML: ⛶ JS: const fullscreen = player.querySelector("#fullscreen"); function openFullscreen() { video.requestFullscreen && video.requestFullscreen(); }; fullscreen.addEventListener("click", openFullscreen); or even with arrow function: fullscreen.addEventListener( "click", () => video.requestFullscreen && video.requestFullscreen() );
@MobileTechGuruji
@MobileTechGuruji 4 года назад
how to prevent video from being download through extension ??
@АндрейМиронов-т9н
why when i switch to fullscreen mode, my controlbar changing back to basic, how do i change it to my custom controlbar? can u share some link to how to do that?
@missgreendayfan
@missgreendayfan 6 лет назад
I'm wondering how to do this too...
@ArpanCodes
@ArpanCodes 5 лет назад
call player.requestFullscreen() it will work! I too had the same problem then I realised I was calling the requestFullscreen() function on video but you have to call it on player! hope that solves your issue
@coows
@coows 5 лет назад
@@ArpanCodes thank you
@ArpanCodes
@ArpanCodes 5 лет назад
@@coows you're welcome 😊
@bengalcat_j4176
@bengalcat_j4176 5 лет назад
@@ArpanCodes finally find a solution, thanks!
@filmyfun9523
@filmyfun9523 5 лет назад
but how to place auto,144p,240p,360p,480p,720p setting on video
@LabhamJain
@LabhamJain 5 лет назад
first you need to convert video then you can use these options
@rockyou4586
@rockyou4586 6 лет назад
Where I can find CSS file, Please??
@PrastutKumar
@PrastutKumar 6 лет назад
github.com/wesbos/JavaScript30/blob/master/11%20-%20Custom%20Video%20Player/style.css
@rockyou4586
@rockyou4586 6 лет назад
How to create a full screen button please please sir
@gx9686
@gx9686 5 лет назад
can we make our style (css/javascript/jquery) on embed youtube player ?
@aburaihan9663
@aburaihan9663 3 года назад
Which theme are you using?
@니꼴라오-i4s
@니꼴라오-i4s 5 лет назад
Where is video source ?
@youthsportsfilms6252
@youthsportsfilms6252 6 лет назад
When I write the code for js: const player = document.querySelector('.player'); I get (Player is defined by never used) How do I fix it? Thanks for any and all help!
@vojtechsebo4119
@vojtechsebo4119 6 лет назад
YOUTH SPORTS FILMS To catch the other elements use player.querySelector instead of document.querySelector.
@VerglasOfficial
@VerglasOfficial 6 лет назад
Why do you need a dot in the querySelector parameter? why is it ('.video') instead of ('video')?
@Ali-lm7uw
@Ali-lm7uw 5 лет назад
If a class is targeted in an HTML element then dot is used before it. In the case of Id, # is used.
@codewithishan8369
@codewithishan8369 4 года назад
Because its a class
@CyberIllusions
@CyberIllusions 7 лет назад
Cool player, Wes! Is it responsive...?
@wilsonmojo2237
@wilsonmojo2237 6 лет назад
CyberIllusions Not responsive
@brazstane1688
@brazstane1688 3 года назад
Please , how to make the "nodownload".
@bokisa007
@bokisa007 7 лет назад
nice video.. noticed you are using const for icon in updateButton method.. Since it changes depending on pause property I believe in this case let is more appropriate. Best of luck
@sgwatyt
@sgwatyt 7 лет назад
The main difference between const and let is let allows for the variable to change its value (for a value type - number, string, boolean) or change its reference for a reference type (object, function, array). In this case const is appropriate since its value (a string) is not being changed once it is assigned. The ternary expression is completely evaluated before any assignment happens, so while the variable could be assigned one of two different values the variable is only ever assigned one/once.
@kissu_io
@kissu_io 6 лет назад
Const *can* be changed, it just cannot be re-assigned or re-declared.
@azizulhakimashik1154
@azizulhakimashik1154 3 года назад
This is the great one :)
@mdhzair8373
@mdhzair8373 3 года назад
Can you upload that project and give us the link
@kashaanmahmood5311
@kashaanmahmood5311 2 года назад
brilliant, thanks
@basantakc2168
@basantakc2168 5 лет назад
element.requestFullscreen() hook up this with your event listener for full screen :)
@codewithishan8369
@codewithishan8369 4 года назад
How to use it
@rockyou4586
@rockyou4586 6 лет назад
big brother your fullscreen how the crew tell your brother's video code two brothers
@emmanuelpraise4701
@emmanuelpraise4701 Год назад
Why didn't you just show us the css at least
@mercyvasquez3634
@mercyvasquez3634 4 года назад
con que teclas hago los iconos?
@marcelo.junior2478
@marcelo.junior2478 5 лет назад
How to put quality, speed and subtitle in the video ?
@weremed
@weremed 5 лет назад
You'd need something like MPEG-DASH for that.
@Ludo045
@Ludo045 2 года назад
this is not beginner at all.
@tannercottle
@tannercottle 4 года назад
theme / font on your IDE?
@JunaidK
@JunaidK 6 лет назад
I'm using Julbul player to customize the look and feel of youtube player and to remove youtube logo from embedded videos :) This player really cutt my cost
@LabhamJain
@LabhamJain 5 лет назад
any url to test it?
@lardosian
@lardosian 7 лет назад
In line 3, why is the selector not ('.player__video viewer'), thanks!
@kissu_io
@kissu_io 6 лет назад
You don't need the entire thing. There are 2 classes, just pick one of them. Or you can player.querySelector('.player__video.viewer') but, what for ?
@FarhanShaikh-sz5ww
@FarhanShaikh-sz5ww 2 года назад
Icons used in the video: '▶' ❚ ❚'
@youthsportsfilms6252
@youthsportsfilms6252 6 лет назад
Can you use Komodo Edit to write this code? Thank you
@kissu_io
@kissu_io 6 лет назад
You even can write on Notepad++ if you wish. But feel free to try some software like Sublime Text, Atom or VScode, they are free.
@dhatturabets444
@dhatturabets444 6 лет назад
Idiot?
@kissu_io
@kissu_io 6 лет назад
Dhattura Bets ?
@TorpisoulYT
@TorpisoulYT 5 лет назад
Struggling at 19:20. I've got the code, I've checked the code vs the above and vs the scripts-FINISHED.js file... My console isn't doing what yours is. Am I being blind? function scrub(e) { console.log(e); } /* Hook up the event listeners*/ video.addEventListener('click', togglePlay); video.addEventListener('play', updateButton); video.addEventListener('pause', updateButton); video.addEventListener('timeupdate', handleProgress); toggle.addEventListener('click', togglePlay); skipButtons.forEach(button => button.addEventListener('click', skip)); ranges.forEach(range => range.addEventListener('change', handleRangeUpdate)); ranges.forEach(range => range.addEventListener('mousemove', handleRangeUpdate)); progress.addEventListener('click', scrub);
@TorpisoulYT
@TorpisoulYT 5 лет назад
found my error. for the const values at the beginning, i was using "preview" not progress.
@tonyi2430
@tonyi2430 5 лет назад
15:42 Don't mind me I'm commenting this for my own reference.
@Splixy
@Splixy 3 года назад
Source code
@frankynakamoto2308
@frankynakamoto2308 5 лет назад
I need a source code for a chess game in Javascript engine with also a music player in, so I can modify the source code to enhance it
@MetsXMFanZonePodcast
@MetsXMFanZonePodcast 8 месяцев назад
an you use this code into a live stream
@benceyt7841
@benceyt7841 6 лет назад
#JavaScript30
@rockyou4586
@rockyou4586 6 лет назад
Hey big brother
@someone11233
@someone11233 5 лет назад
I need its css source code
@rockyou4586
@rockyou4586 6 лет назад
Tell my sir
@kickbuttowsk2i
@kickbuttowsk2i 4 года назад
npm uninstall video.js, thanks wes
@oisterzenitzer9748
@oisterzenitzer9748 Год назад
somehow i managed to make the full screen button work. Took me some time to get it in agreement with already declared css rules and class names. html: ⛶ css: .player__Fullscreen { font-size: 15px; font-weight: bolder; color: white; cursor: pointer; } .player__Fullscreen:hover { color: aqua; } javascript: /* Get the elements */ const fScreen = player.querySelector(".player__Fullscreen"); /* Build the functions*/ function toggleFullScreen() { if (video.requestFullscreen) { video.requestFullscreen(); } else if (video.webkitRequestFullscreen) { /* Safari */ video.webkitRequestFullscreen(); } else if (elem.msRequestFullscreen) { /* IE11 */ video.msRequestFullscreen(); } } /* Hook up event listeners */ fScreen.addEventListener("click", toggleFullScreen);
@rockyou4586
@rockyou4586 6 лет назад
big brother your fullscreen how the crew tell your brother's video code two brothers
@davidmailler1180
@davidmailler1180 6 лет назад
Where I can find CSS file, Please??
@PrastutKumar
@PrastutKumar 6 лет назад
github.com/wesbos/JavaScript30/blob/master/11%20-%20Custom%20Video%20Player/style.css
Далее
How is this Website so fast!?
13:39
Просмотров 501 тыс.
Борщ в стиле высокой кухни!
00:57
She Couldn’t Believe I Did This! 😭 #shorts
00:12
Why did OpenAI move from Next.js to Remix?
10:41
Просмотров 171 тыс.
These CSS PRO Tips & Tricks Will Blow Your Mind!
8:48
Просмотров 422 тыс.
Introduction to shaders: Learn the basics!
34:50
Просмотров 348 тыс.
Ajax Type Ahead with fetch() - #JavaScript30 6/30
17:22
Борщ в стиле высокой кухни!
00:57