Javascript JWPlayer-未定义不是函数

Javascript JWPlayer-未定义不是函数,javascript,jwplayer,Javascript,Jwplayer,我想知道是否有人能帮我 我试图使用jwplayer加载视频,但我遇到了错误 这是我使用的代码 <script type="text/javascript"> jwplayer("legacyPlayer").setup({ width:370, height:240, file: "https://s3.amazonaws.com/legacy/vi

我想知道是否有人能帮我

我试图使用jwplayer加载视频,但我遇到了错误

这是我使用的代码

        <script type="text/javascript">
            jwplayer("legacyPlayer").setup({
                width:370,
                height:240,
                file: "https://s3.amazonaws.com/legacy/videoname.mp4",
            });
        </script>

        <div id="legacyPlayer" align="center"></div>
任何帮助这项工作将不胜感激


干杯,

您应该在HTML标记后放置脚本块,如下所示:

<div id="legacyPlayer" align="center"></div>
<script type="text/javascript">
    jwplayer("legacyPlayer").setup({
        width:370,
        height:240,
        file: "https://s3.amazonaws.com/legacy/videoname.mp4",
    });
</script>

jwplayer(“legacyPlayer”)。设置({
宽度:370,
身高:240,
文件:“https://s3.amazonaws.com/legacy/videoname.mp4",
});

当浏览器文档解析器遇到脚本标记时,它将停止解析页面上的其他html内容,直到脚本下载并执行为止。这意味着当您试图在脚本块中操作“legacyPlayer”时,它不存在。这就是“undefined is not a function”(jwplayer选择器找不到ID为legacyPlayer的DOM)错误的根本原因。

请确保您的div ID=“container”等于jwplayer(“container”)名称

正在加载播放器。。。
var playerInstance=jwplayer(“容器”);
playerInstance.setup({
文件:“//content.jwplatform.com/videos/3XnJSIm4-640.mp4”,
图片:“//content.jwplatform.com/thumbs/3XnJSIm4-640.jpg”,
宽度:640,
身高:270,
标志:{
文件:“//content.jwplatform.com/watermarks/gdz4zR4a.png”,
链接://www.blender.org/foundation/“
},
abouttext:“Blender.org上提供视频”,
关于链接:'http://www.blender.org'
});

尝试删除
文件中的最后一个
:https://s3.amazonaws.com/legacy/videoname.mp4“,
并且您还可以创建包含外部js文件的小提琴吗?您知道错误消息的含义吗?我不确定小提琴是什么。。。我不知道错误消息是什么意思,但当我在控制台中单击错误时,它指向第一行开始的“jwplayer”,div需要位于播放器设置之上。非常感谢,这是一个非常简单的解决方案哈哈。。再次感谢!
<div id="legacyPlayer" align="center"></div>
<script type="text/javascript">
    jwplayer("legacyPlayer").setup({
        width:370,
        height:240,
        file: "https://s3.amazonaws.com/legacy/videoname.mp4",
    });
</script>
<div id="container">Loading the player...</div>

    <script type="text/javascript">

        var playerInstance = jwplayer('container');
        playerInstance.setup({
            file: "//content.jwplatform.com/videos/3XnJSIm4-640.mp4",
            image: "//content.jwplatform.com/thumbs/3XnJSIm4-640.jpg",
            width: 640,
            height: 270,
            logo: {
                file: "//content.jwplatform.com/watermarks/gdz4zR4a.png",
                link: "//www.blender.org/foundation/"
            },
            abouttext: 'Video Available at Blender.org',
            aboutlink: 'http://www.blender.org'
        });
    </script>

</div>