HTML 5 Video Tag not working from Tomcat (Edited)

后端 未结 3 1881
离开以前
离开以前 2021-01-17 05:22

Video not playing from the Tomcat 7 server using absolute path & relative path of the file:

Edit Summary: Altered the example for the relative path, and i am pla

相关标签:
3条回答
  • 2021-01-17 06:01

    That's for security reason. Pages loaded from some server can't load files from local drive. Copy video to src/main/webapp/video.m4v. Change JSP to this:

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <!doctype html>
    
    <html>
    
    <head>
    <title>Cluster Video App</title>
    <script type="text/javascript">
    
    </script>
    </head>
    
    <body>
        <h1>Enjoy the Video</h1>
    
        <video controls autoplay width="512" height="288">
            <source src="<c:url value="/video.m4v" />"> </source>
        </video>
    </body>
    </html>
    
    0 讨论(0)
  • 2021-01-17 06:15

    How about check the video.js It really works. I tested with Apache-Tomcat 8.5.

    First, include these two lines

    <link href="//vjs.zencdn.net/5.11/video-js.min.css" rel="stylesheet">
    <script src="//vjs.zencdn.net/5.11/video.min.js"></script>
    

    and use video tag like this.

    <video
        id="my-player"
        class="video-js"
        controls
        preload="auto"
        poster="//vjs.zencdn.net/v/oceans.png"
        data-setup='{}'>
      <source src="//vjs.zencdn.net/v/oceans.mp4#t=5,10" type="video/mp4"></source>
      <source src="//vjs.zencdn.net/v/oceans.webm" type="video/webm"></source>
      <source src="//vjs.zencdn.net/v/oceans.ogv" type="video/ogg"></source>
      <p class="vjs-no-js">
        To view this video please enable JavaScript, and consider upgrading to a
        web browser that
        <a href="http://videojs.com/html5-video-support/" target="_blank">
          supports HTML5 video
        </a>
      </p>
    </video>
    
    0 讨论(0)
  • 2021-01-17 06:17

    place the the folder inside your WebContent folder or webapps folder then give path like ./folder1/file.mp4 if WebContent is not there then create a new project setup using eclipse with DynamicWebProject paste the tour files inside that.

    i am also getting this issue but now its [SOLVED] and i am using tomcat 8 and java 7

    0 讨论(0)
提交回复
热议问题