简体   繁体   English

url.content显示相同的视频

[英]url.content showing the same video

Please help me find what I am missing. 请帮助我找到我所缺少的。 url.content is not returning each item's video in a foreach loop instead it is showing the same video for each element. url.content不会在foreach循环中返回每个项目的视频,而是为每个元素显示相同的视频。 I would like to access each video in the videofilepath column of my table and display it on a modal (still a work in progress). 我想访问表中videofilepath列中的每个视频,并将其显示在模式中(仍在进行中)。

@foreach (var item in Model)
{
    <div class="col-md-4 portfolio-item">
        <img class="img-responsive img-thumbnail" 
        src='@item.PosterFilePath'alt="thumbnail" />

        <strong> @Html.DisplayNameFor(model => model.Title)</strong>
        @Html.DisplayFor(modelItem => item.Title)
        <br>
        <strong>@Html.DisplayNameFor(model => model.ReleaseDate)</strong>
        @Html.DisplayFor(modelItem => item.ReleaseDate)
        <br>
        <strong>@Html.DisplayNameFor(model => model.Genre)</strong>
        @Html.DisplayFor(modelItem => item.Genre)
        <br>
        <strong> @Html.DisplayNameFor(model => model.Price)</strong>
        @Html.DisplayFor(modelItem => item.Price)
        <br>
        <strong>@Html.DisplayNameFor(model => model.Rating)</strong>
        @Html.DisplayFor(modelItem => item.Rating)
        <br>
        <div class="">
            <button class="btn btn-primary" type="button" data-toggle="modal" data-target="#ajax">Watch now</button>
            <button class="btn btn-success" type="button"><span class="glyphicon-download"></span>Download</button>
        </div>

        <br>

        @Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
        @Html.ActionLink("Details", "Details", new { id = item.ID }) |
        @Html.ActionLink("Delete", "Delete", new { id = item.ID })

    </div>

    <div class="modal fade" id="ajax">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                   <h3>@Html.DisplayNameFor(model => model.Title)</h3>
                </div>
                <div class="modal-body">
                   <video id="video" poster="~/Images/algo.jpg"
                           controls="controls"
                           loop="loop">
                        <source src="@Url.Content(item.VideoFilePath)" type="video/mp4">
                    </video>
                </div>
                <div class="modal-footer">
                    <button type="button" id="btnClose" class="btn btn-primary" data-dismiss="modal"><span class="glyphicon-folder-close"></span>Close</button>
                    <button type="button" class="btn btn-success">Download</button>
                </div>
            </div>
        </div>
    </div>
}

Your modal div needs to have a unique Id. 您的模式div需要具有唯一的ID。 If you have the Id of the video for example as part of the Model, you could prepend or append it: 例如,如果您将视频的ID作为模型的一部分,则可以在视频ID之前或附加以下内容:

<div class="modal fade" id="ajax@(Model.VideoId)"

and the same with the button that invokes it: 和调用它的按钮相同:

<button class="btn btn-primary" type="button" data-toggle="modal" data-target="#ajax@(Model.VideoId)">Watch now</button>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM