如何将我的函数changeVideoSource链接到我的视频标签?我从mySQL检索视频数据,我想显示视频,我正在使用Java Spring Boot。
<body>
<div class="jumbotron col-xs-12" th:each="film: ${films}">
<p th:text="${film.titre}"/>
<video id="video" width="200" height="200" th:onloadstart="changeVideoSource(${film.filmvideo}, this.id)" controls>
</video>
</div>
</body>
<script type="text/javascript">
function changeVideoSource(blob, videoElement)
{
var blobUrl = URL.createObjectURL(blob);
console.log(Changing video source to blob URL "${blobUrl}");
videoElement.src = blobUrl;
videoElement.play();
}
</script>发布于 2020-11-22 02:36:27
尝试以下修改:
<div class="jumbotron col-xs-12" th:each="film: ${films}">
<p th:text="${film.titre}" />
<video id="myVideoTag" width="200" height="200" controls> </video>
</body>
<script type="text/javascript">
///# setup the vars
var myVid = document.getElementById( "myVideoTag" );
var myBlob = ${film.filmvideo};
//# run the function
myFunc( myBlob, myVid )
function myFunc( videoElement)
{
console.log( "videoElement is : " + videoElement );
var blobUrl = (window.URL || window.webkitURL).createObjectURL(blob);
console.log(Changing video source to blob URL "${blobUrl}");
videoElement.src = blobUrl;
videoElement.play();
}
</script>https://stackoverflow.com/questions/64943738
复制相似问题