HTML YouTube video
- Previous Page HTML video
- Next Page HTML5 introduktion
Den enkleste måde at inkludere videoer i HTML er ved at bruge YouTube.
Vanskelig ved videoformater?
Det kan være både svært og tidskrævende at konvertere videoer til forskellige formater.
En enklere løsning er at lade YouTube afspille videoen i din hjemmeside.
YouTube Video Id
Når du gemmer (eller afspiller) videoen, viser YouTube en id (f.eks. ih1l6wb7LhU).
Du kan bruge denne id og citere din video i HTML-koden.
Indsæt YouTube-video i HTML
Hvis du vil afspille videoen på din hjemmeside, skal du følge disse trin:
- Upload videoen til YouTube
- Noter video id
- definere i din hjemmeside
<iframe>
elementet - Lad
src
egenskab til at pege på videoens URL - Brug
width
ogheight
Brug egenskaber til at definere spillerens størrelse - Tilføj andre parametre til URL'en (se nedenfor)
Eksempel
<iframe width="420" height="315" src="https://www.youtube.com/embed/ih1l6wb7LhU"> </iframe>
YouTube Autoplay + Lydløs
Du kan få videoen til at starte automatisk, når brugeren besøger siden, ved at tilføje autoplay=1 til YouTube URL'en. Men, automatisk start af videoer kan irritere dine besøgende!
Note:In most cases, Chromium browsers do not allow autoplay. But always allow muted autoplay.
In autoplay=1
Add after mute=1
, allowing your video to start playing automatically (but muted).
YouTube - Autoplay + Muted
<iframe width="420" height="315" src="https://www.youtube.com/embed/ih1l6wb7LhU?autoplay=1&mute=1"> </iframe>
YouTube Playlist
List of videos to play separated by commas (excluding the original URL).
YouTube Loop
Add loop=1
This will make your video loop forever.
Value 0 (default): The video will play once.
Value 1: The video will loop (forever).
YouTube - Loop
<iframe width="420" height="315" src="https://www.youtube.com/embed/ih1l6wb7LhU?playlist=ih1l6wb7LhU&loop=1"> </iframe>
YouTube Controls
Add controls=0
This will make the video player not display controls.
Value 0: Player controls are not displayed.
Value 1 (default): Player controls are displayed.
YouTube - Controls
<iframe width="420" height="315" src="https://www.youtube.com/embed/ih1l6wb7LhU?controls=0"> </iframe>
- Previous Page HTML video
- Next Page HTML5 introduktion