我有一个名为视频的模型:
public class Video
{
public int ID { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string VideoLink { get; set; }
public string tags { get; set; }
}
假设我使用 CRUD Controller ,使用上述模型,并使用 Title
、Description
和 VideoLink
创建一个新视频,
创建后,URL 显示为文本而不是 YouTube 视频。
最佳答案
您可以使用video
标签:
<video src="@item.VideoLink"></video>
更新:
YouTube players can be embedded in a web page using either an tag or an tag. By appending parameters to the IFrame or SWF URL, you can customize the playback experience in your application. For example, you can automatically play videos using the autoplay parameter or cause a video to play repeatedly using the loop parameter. You can also use the enablejsapi parameter to enable the player to be controlled via the IFrame Player API. more info
<object width="640" height="390">
<param name="movie"
value="@item.VideoLink"></param>
<param name="allowScriptAccess" value="always"></param>
<embed src="@item.VideoLink"
type=" application />x-shockwave-flash"
allowscriptaccess="always"
width="640" height="390"></embed>
</object>
关于c# - 如何使用 asp.net MVC 通过模型属性显示 YouTube 链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32274788/