Embed Youtube Code Is Not Working in HTML

Embeded YouTube video not available in iframe HTML

YouTube forbids embedding some videos in a localhost environment without a public domain, but your video can be embedded with no issue through a public domain/ sub-domain try the same using webhosting apps or online html tools.

My youtube embed code doesn't work on html website

You have to enable embedding first before the embed code will work from other websites.

  • Log in to https://www.youtube.com/my_videos?o=U
  • Click Edit on the video you want to embed
  • Click on Advanced Settings in the tab below
  • Click Allow Embedding to enable it under the Distribution options section.
  • Click Save Changes to save the new configuration.
  • Now your embed link is ready to be embedded on other websites!

Embedded YouTube video doesn't work on local server

Sergiy Shcherbina's answer helped me solve this issue. I was running my web server from a vm and accessing it through my local IP address.

It seems that you need to access your page that contains the embedded youtube player through a host name and NOT an IP address.

How I solved This for my dev environment

Before the change, I was accessing my web-page like this: http://192.168.x.x:3000/video and i would get 'video unavailable' errors for many videos that were verifiably 'embeddable'.

A Hacky word-around: I set a hostname for my VM in my hosts file and aliased my IP address to dev-vm. How to edit your host file

Now i access the page which has my embedded player like this: http://dev-vm:3000/video and now videos that previously gave me a 'video unavailable' error are now playing.

What a bizarre issue. I hope this helps some people who are having a similar issue.

HTML: Input YouTube Video embed link not working

Regular Expressions can be useful for this kind of validation.
For client-side validation:

function validateYoutubeURL(url){
var regex=/https?:\/\/youtu(be\.com|\.be)\/.+/;
return regex.test(url.toLowerCase());
}

And for server-side validation:

public function store(Request $request){
$this->validate($request, [
'field_name'=> [
'required',
'regex:/https?:\/\/youtu(be\.com|\.be)\/.+/',
]
]);
}

In order to notify user about wrong URL, use this (Server-Side validation):

@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif

Important:

Note: When using the regex / not_regex patterns, it may be necessary to specify rules in an array instead of using pipe delimiters, especially if the regular expression contains a pipe character.

For third part of your question, please post your view and controller.



Related Topics



Leave a reply



Submit