嵌入式 YouTube 视频不适用于 asp.net MVC/Angular 应用

Embedded YouTube video is not working on asp.net MVC/Angular app

我已尝试在我的 asp.net mvc 应用程序中嵌入如下所示的视频。

<div class="col-lg-12 center " data-animation="bounceInRight" data-delay="300">
     <iframe width="170" height="128" ng-src="https://www.youtube.com/embed/watch?v=1aDLYFBuWc8" frameborder="0" allowfullscreen style="max-width:100%; margin:0 auto; display:block;"></iframe>
</div>

但是当我尝试播放时,它显示以下错误。

没有 console window errors.When 我试图通过右键单击上面的视频来获取 url 然后它显示了这个:https://youtu.be/undefined

但是当我嵌入下面那种 url 时,它工作正常。

https://www.youtube.com/embed/A6XUVjK9W4o 

你能告诉我如何解决这个问题吗?提前致谢。

答案: 我想如果我像下面提到的@Jossef Harush那样使用Video_Id,我可以避免这个问题。

转到想要的 Youtube 视频并单击“分享”,然后您将看到一个代码片段选项,您可以将其嵌入到您的代码中。

这是 yt 的默认值

<iframe width="420" height="315" src="Link here" frameborder="0" allowfullscreen></iframe>

不好 url 你不能使用 ng-src 试试这个:

<div class="col-lg-12 center " data-animation="bounceInRight" data-delay="300">
     <iframe width="170" height="128" src="https://www.youtube.com/embed/1aDLYFBuWc8?rel=0" frameborder="0" allowfullscreen="" style="max-width:100%; margin:0 auto; display:block;"></iframe>
</div>

http://jsfiddle.net/6w3ao4ft/

在冗余中使用 ng-src

因为您没有在示例中动态设置视频 url。无需使用 ng-src

YouTube 嵌入 URL 不正确

来自他们 docs:

Embed a player using an tag

Define an tag in your application in which the src URL specifies the content that the player will load as well as any other player parameters you want to set. The tag's height and width parameters specify the dimensions of the player.

If you create the element yourself (rather than using the IFrame Player API to create it), you can append player parameters directly to the end of the URL. The URL has the following format:

http://www.youtube.com/embed/VIDEO_ID

使用https://www.youtube.com/embed/A6XUVjK9W4o 代替https://www.youtube.com/embed/watch?v=1aDLYFBuWc8

Sample on Plunker