簡體   English   中英

Jwplayer視頻播放器無法正常工作

[英]Jwplayer video player not working

我正在嘗試設置Jwplayer視頻播放器,但是什么也沒出現,根本沒有顯示視頻播放器。 我按照說明進行操作時,我在做錯什么,但是視頻文件來自數據庫,而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>

好的,是發生了什么事,當我使用$ GET方法從上一頁(使用超鏈接)獲取視頻的文件名時,它會打開一個新頁面,其網址為:

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

當我嘗試檢索視頻文件時,在數據庫中,該文件以VideoFiles/sample_mpeg4_5.mp4形式存儲在數據庫中。

這是因為視頻存儲在VideoFiles文件夾中

現在,此時顯示一個黑色方塊,視頻播放器應該在該方塊中指出:

Error loading player:
No playable sources found

我是否需要包括jwplayer.html5.js的js文件,我是否缺少任何可能需要的其他文件,或者是其他問題嗎?

螢火蟲:

使用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",
    });

圖片:

下面顯示圖像代碼:

如果我選擇一個稱為Tulips_3.png的超鏈接,則該URL顯示為:

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

但是我要做的就是使用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>

更新2

<script type="text/javascript">

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

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

輸出:這是$ dbVideoFile:VideoFile‌s / sample_mpeg4_5.mp4`

希望對您有所幫助。

您的腳本中有錯字:

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

應該:

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

注意額外的問號“?” 在開始的php-tag中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM