JS中的变量传递问题,视频幻灯片

时间:2012-05-17 14:46:41

标签: php javascript html flowplayer

我想在用户发布视频之前为我的视频设置一个预览系统,我需要能够从数据库中检索多个文件并相应地创建视频。我有一个按钮

<a class="btnGray clickable floatRight" style="position:relative;" onclick="startVideo('<?=$content[ReleaseSystem::contentID]?>','<?=$video['filename']?>');"><?=$lang[109]?></a>

此按钮链接到以下功能

function startVideo(id,link) {
    $("#"+id).fadeIn("slow", function() {
        $f("player", {src: "players/nobranding.swf", wmode: 'opaque'},
            {
                clip: { autoPlay: true },
                playlist: ['videos/IMPORTS/'+link,],
                plugins: { controls: { playlist: true }}
            }
        ).ipad();
    });
}

现在奇怪的是,当我不通过我的按钮上的链接时视频播放器加载但是当我尝试发送链接时整个功能崩溃。我不知道为什么会发生这种情况。

这里也是播放器的html代码

<div id="videoFlyout<?=$content[ReleaseSystem::contentID]?>" class="popUpWrapper" style="display:none;position:absolute;top:10px;left:auto;">
    <div class="firstPopupDiv" style="left:center;height:425px;width:620px;">
        <div class="popupDivInner" style="display:block;" class="hideSteps">
            <div id="<?=$content[ReleaseSystem::contentID]?>">
                <center><a id="player" style="display:block; height:365px; width:620px;"></a></center>
            </div>
            <a class="btnRed clickable floatRight" style="position:relative;" onclick="closeVideo(<?=$content[ReleaseSystem::contentID]?>);"><?=$lang[109]?></a>
            <a class="btnGray clickable floatRight" style="position:relative;" onclick="startVideo('<?=$content[ReleaseSystem::contentID]?>','<?=$video['filename']?>');"><?=$lang[109]?></a>
        </div>
    </div>
</div>

这是我渲染的HTM

<div id="videoFlyout280" class="popUpWrapper" style="position: absolute; top: 10px; left: auto; display: none;">
    <div class="firstPopupDiv" style="left:center;height:425px;width:620px;">
        <div class="popupDivInner" style="display:block;">
            <div id="280" style="">
            <center>
            <a id="player" style="display:block; height:365px; width:620px;">
                <object id="player_api" width="100%" height="100%" type="application/x-shockwave-flash" data="players/nobranding.swf">
                    <param value="true" name="allowfullscreen">
                    <param value="always" name="allowscriptaccess">
                    <param value="high" name="quality">
                    <param value="false" name="cachebusting">
                    <param value="#000000" name="bgcolor">
                    <param value="opaque" name="wmode">
                    <param value="config={"clip":{"autoPlay":true},"playlist":[{"url":"videos/IMPORTS/video_1011_281_1337198589_VID_20120511_00000.3GP","autoPlay":true}],"plugins":{"controls":{"playlist":true}},"playerId":"player"}" name="flashvars">
                </object>
            </a>
            </center>
        </div>
        <a class="btnRed clickable floatRight" onclick="closeVideo(280);" style="position:relative;">Cancel</a>
        <a class="btnGray clickable floatRight" onclick="startVideo('280','video_1011_280_1337183112_testCat.mp4');" style="position:relative;">Cancel</a>
        </div>
    </div>
</div>
<div id="videoFlyout281" class="popUpWrapper" style="position: absolute; top: 10px; left: auto;">
    <div class="firstPopupDiv" style="left:center;height:425px;width:620px;">
        <div class="popupDivInner" style="display:block;">
            <div id="281" style="">
            <center>
                <a id="player" style="display:block; height:365px; width:620px;"> </a>
            </center>
            </div>
            <a class="btnRed clickable floatRight" onclick="closeVideo(281);" style="position:relative;">Cancel</a>
            <a class="btnGray clickable floatRight" onclick="startVideo('281','video_1011_281_1337198589_VID_20120511_00000.3GP');" style="position:relative;">Cancel</a>
        </div>
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

很难在没有错误消息和呈现HTML的情况下确切地说出发生了什么,但有一点是startVideo(<?=$video['filename']?>);应该是startVideo('<?=$video['filename']?>');,看起来你的意思是传入一个字符串并且您正在传递JavaScript解释为undefined全局变量的内容。

如果这样可以解决您的问题!否则请将上述项目发布以供进一步调查。