video.js techOrder flash - no compatible source wa

2019-08-14 05:24发布

问题:

Whenever I try to run a video with data-setup='{"techOrder": ["flash"]}' set at only flash I can't make it work.

  • Here is a fiddle http://jsfiddle.net/a9uvasrh/5/
  • The fiddle from this other SO Q&A also doesn't load for me Video.js Force Flash Controls Display

Tested on Chrome, Opera, FF and IE . Only the last 2 show the message "no compatible source was found for this video"; the others remain unresponsive.


Edit: The issue is present in local storage as well

<html>
    <head>
        <script src="http://vjs.zencdn.net/c/video-js.css"></script>
        <script src="http://vjs.zencdn.net/c/video.js"></script>
    </head>
    <body>
        <div class="container">
            <video id="example_video_1" class="video-js vjs-default-skin"
              controls preload="auto" width="640" height="264"
              poster="http://video-js.zencoder.com/oceans-clip.png"
              data-setup='{"techOrder": ["flash"]}'>
                 <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
                 <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
                 <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />
                 <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>
        </div>

    </body>
</html>

The code above initializes the flash player (VideoJS Flash component v3.0 appears in the dropdown menu) but it doesn't run the video.

回答1:

This is because jsfiddle is now using the sandbox attribute on the iframe the results are shown in. The effect of that varies: In Chrome the swf is loaded but Flash's ExternalInterface is blocked, so the swf can't be told to do anything. In Firefox the swf doesn't even get loaded.

jsbin's also uses an iframe with sandbox in edit mode, but works fine out of edit mode as no iframe is used.

Assuming that "local storage" means the html is being loaded in the browser with the file:// protocol then the problem is also the browser blocking ExternalInterface script access, but for a different reason. Here it's because browsers block script access to a swf loaded over one protocol (http) from a page loaded over another (file).