简体   繁体   English

Jwplayer视频播放器无法正常工作

[英]Jwplayer video player not working

I am trying to set up Jwplayer video player but nothing is appearing, no video player is being displayed at all. 我正在尝试设置Jwplayer视频播放器,但是什么也没出现,根本没有显示视频播放器。 What am I doing wrong in the set up as I have followed the instructions but the video file is coming from a database and the mysqli is definitely correct: 我按照说明进行操作时,我在做错什么,但是视频文件来自数据库,而mysqli绝对正确:

    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <title>Preview Video</title>
        <script type="text/javascript" src="jquery/jwplayer.js"></script>

    </head>

    <body>

    <?php

    $getvideo = 'VideoFiles/' . $_GET['filename'];

    $videoquery = "SELECT VideoFile FROM Video WHERE (VideoFile = ?)";

            if (!$videostmt = $mysqli->prepare($videoquery)) {
            // Handle errors with prepare operation here
    }


    // Bind parameter for statement
    $videostmt->bind_param("s", $getvideo);

    // Execute the statement
    $videostmt->execute();

                if ($videostmt->errno) 
                {
                    // Handle query error here
                }


    $videostmt->fetch(); 

    $videostmt->close(); 

    ?>

    <div id="myElement">Loading the player...</div>

    <script type="text/javascript">
        jwplayer("myElement").setup({
            file: "<php echo $getvideo ?>",
            image: "/uploads/example.jpg",
        });
    </script>


**UPDATE:**

Current code:

<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title>Preview Video</title>
    <script type="text/javascript" src="jquery/jquery-1.7.min.js"></script>   
    <script type="text/javascript" src="jquery/jwplayer.js"></script>

</head>

<body>

<?php

$getvideo = 'VideoFiles/' . $_GET['filename'];

$videoquery = "SELECT VideoFile FROM Video WHERE (VideoFile = ?)";

        if (!$videostmt = $mysqli->prepare($videoquery)) {
        // Handle errors with prepare operation here
}


// Bind parameter for statement
$videostmt->bind_param("s", $getvideo);

// Execute the statement
$videostmt->execute();

            if ($videostmt->errno) 
            {
                // Handle query error here
            }

 $videostmt->bind_result($dbVideoFile); 

$videostmt->fetch(); 

$videoPath='http://domain.com/videos/'.$dbVideoFile;

$videostmt->close(); 

?>

<div id="myElement">Loading the player...</div>

<script type="text/javascript">
    jwplayer("myElement").setup({
        file: "<php echo $videoPath ?>",
        image: "example.jpg",
    });
</script>

</body>

Ok what is happening is that when I use the $GET method to get the video's file name from a previous page (using a hyperlink), it opens up a new page and the url is this: 好的,是发生了什么事,当我使用$ GET方法从上一页(使用超链接)获取视频的文件名时,它会打开一个新页面,其网址为:

http://helios.hud.ac.uk/u05454444/Mobile_app/previewvideo.php?filename=sample_mpeg4_5.mp4

In the database when I try to retrieve the video file, it is stored in the database as VideoFiles/sample_mpeg4_5.mp4 . 当我尝试检索视频文件时,在数据库中,该文件以VideoFiles/sample_mpeg4_5.mp4形式存储在数据库中。

This is because the videos are stored in the VideoFiles folder 这是因为视频存储在VideoFiles文件夹中

Now at moment it is display a black square where the video player is suppose to be stating: 现在,此时显示一个黑色方块,视频播放器应该在该方块中指出:

Error loading player:
No playable sources found

Do I need to include the js file of jwplayer.html5.js , am i missing any other files that may be needed or is it something else which is the problem? 我是否需要包括jwplayer.html5.js的js文件,我是否缺少任何可能需要的其他文件,或者是其他问题吗?

FIREBUG: 萤火虫:

Using Firebug I have the following HTML below which contains the html for where the video player is displayed: 使用Firebug,我下面有以下HTML,其中包含视频播放器的显示html:

<div style="position: absolute;">
    <object id="_GPL_swf" width="1" height="1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"
    classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
        <param value="http://shoppingside-a.akamaihd.net/items/it/swf/f.swf" name="movie">
        <param value="high" name="quality">
        <param value="transparent" name="wmode">
        <param value="always" name="allowScriptAccess">
        <param value="keywordsURL=http%3A//i.trkjmp.com/kwd%3Fc%3DOjo6aGVsaW9zLmh1ZC5hYy51azp6LTEyMjItMTIwODcw%26cb%3D_GPL.items.a652c.displayKeywords&keywords=error%20loading%20player%7Cno%20playable%20sources%20found"
        name="flashVars">
        <object id="_GPL_swf" width="1" height="1" type="application/x-shockwave-flash"
        data="http://shoppingside-a.akamaihd.net/items/it/swf/f.swf">
            <param value="high" name="quality">
            <param value="transparent" name="wmode">
            <param value="always" name="allowScriptAccess">
            <param value="keywordsURL=http%3A//i.trkjmp.com/kwd%3Fc%3DOjo6aGVsaW9zLmh1ZC5hYy51azp6LTEyMjItMTIwODcw%26cb%3D_GPL.items.a652c.displayKeywords&keywords=error%20loading%20player%7Cno%20playable%20sources%20found"
            name="flashVars">
        </object>
    </object>
</div>
<div id="_GPL_e6a00_parent_div" style="position: absolute; top: 0px; left: 0px; width: 1px; height: 1px; z-index: 2147483647;">
    <object id="_GPL_e6a00_swf" width="1" height="1" type="application/x-shockwave-flash"
    data="http://shoppingside-a.akamaihd.net/items/e6a00/storage.swf">
        <param name="wmode" value="transparent">
        <param name="allowscriptaccess" value="always">
        <param name="flashvars" value="logfn=_GPL.items.e6a00.log&onload=_GPL.items.e6a00.onload&onerror=_GPL.items.e6a00.onerror&LSOName=gpl">
    </object>
</div>
<div id="myElement" style="width: 480px; height: 270px; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); display: table; opacity: 1;">
    <p style="vertical-align: middle; text-align: center; display: table-cell; font: 15px/20px Arial,Helvetica,sans-serif;">Error loading player:
        <br>No playable sources found</p>
</div>
<script type="text/javascript">
    jwplayer("myElement").setup({
        file: "<php echo $videoPath ?>",
        image: "example.jpg",
    });

IMAGE: 图片:

Below is displaying image code: 下面显示图像代码:

If I select a hyperlink known as Tulips_3.png , then the url is displays in url is this: 如果我选择一个称为Tulips_3.png的超链接,则该URL显示为:

http://helios.hud.ac.uk/u05545444/Mobile_app/previewimage.php?filename=Tulips_3.jpg

Yet all I do is retrieve the filename using the get method, find the image in database with its directory in front ImageFiles/ as the image in database is saved as ImageFiles/Tulips_3.png and then display the image using source, code is below: 但是我要做的就是使用get方法检索文件名,在数据库中找到其目录位于ImageFiles/前面的图像,因为数据库中的图像另存为ImageFiles/Tulips_3.png ,然后使用源代码显示该图像,代码如下:

    <body>

    <?php

    $getimage = 'ImageFiles/' . $_GET['filename'];

    $imagequery = "SELECT ImageFile FROM Image WHERE (ImageFile = ?)";

            if (!$imagestmt = $mysqli->prepare($imagequery)) {
            // Handle errors with prepare operation here
    }


    // Bind parameter for statement
    $imagestmt->bind_param("s", $getimage);

    // Execute the statement
    $imagestmt->execute();

                if ($imagestmt->errno) 
                {
                    // Handle query error here
                }


$imagestmt->bind_result($dbImageFile);

$imagestmt->fetch(); 

$imagestmt->close(); 

?>

<p><img alt="<?php echo $dbImageFile; ?>" height="200" width="200" src="<?php echo $dbImageFile; ?>"></p>


    </body>

UPDATE 2 : 更新2

<script type="text/javascript">

jwplayer("myElement").setup({
    file: "<?php echo $dbVideoFile; ?>",
    image: "example.jpg",
});
</script>

echo 'this is $dbVideoFile: '.$dbVideoFile;

output: this is $dbVideoFile: VideoFile‌​s/sample_mpeg4_5.mp4` 输出:这是$ dbVideoFile:VideoFile‌s / sample_mpeg4_5.mp4`

Hope it's help. 希望对您有所帮助。

You have a typo in your script: 您的脚本中有错字:

<script type="text/javascript">
    jwplayer("myElement").setup({
        file: "<php echo $videoPath ?>",
        image: "example.jpg",
    });
</script>

should be: 应该:

<script type="text/javascript">
    jwplayer("myElement").setup({
        file: "<?php echo $videoPath ?>",
        image: "example.jpg",
    });
</script>

Note the extra questionmark "?" 注意额外的问号“?” in the starting php-tag. 在开始的php-tag中。

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

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