使用 Javascript 更改 Flash 视频

发布于 2024-11-07 16:05:56 字数 4194 浏览 0 评论 0原文

可能的重复:
使用 jquery 更改 flash src?

编辑 我解决了第一个问题(根本没有加载),所以我把那部分拿出来

我有一个我制作的flashplayer,如下所示:

<div id="video_content"><div id="flash_wrapper">
                <object classid="MyID" width="402" height="285" id="videoplayer" align="middle">
                    <param name="movie" value="videoplayer.swf" />
                    <param name="quality" value="high" />
                    <param name="bgcolor" value="#000000" />
                    <param name="play" value="true" />
                    <param name="loop" value="true" />
                    <param name="wmode" value="window" />
                    <param name="scale" value="showall" />
                    <param name="menu" value="true" />
                    <param name="devicefont" value="false" />
                    <param name="salign" value="" />
                    <param name="allowScriptAccess" value="sameDomain" />
                    <param name="allowFullScreen" value="true" />
                    <param name="FlashVars" value="screencast_url=myVideo.flv" id="flash" />
                    <!--[if !IE]>-->
                    <object type="application/x-shockwave-flash" data="videoplayer.swf" width="402" height="285">
                        <param name="movie" value="videoplayer.swf" />
                        <param name="quality" value="high" />
                        <param name="bgcolor" value="#000000" />
                        <param name="play" value="true" />
                        <param name="loop" value="true" />
                        <param name="wmode" value="window" />
                        <param name="scale" value="showall" />
                        <param name="menu" value="true" />
                        <param name="devicefont" value="false" />
                        <param name="salign" value="" />
                        <param name="allowScriptAccess" value="sameDomain" />
                        <param name="allowFullScreen" value="true" />
                        <param name="FlashVars" value="screencast_url=myVideo.flv" id="flash" />

                    <!--<![endif]-->
                        <a href="http://www.adobe.com/go/getflash">
                            <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
                        </a>
                    <!--[if !IE]>-->
                    </object>
                    <!--<![endif]-->
                </object>
            </div>

我有一些按钮,我想用它们来更改视频播放。更改视频的js方法如下所示:

function ChangeVideo(videoIndex) {

//Video Location String
var vidLocation = "screencast_url=";

//Determines what video to load
switch (videoIndex) {
    case 1:
        //Change Video Location
        vidLocation += "myVideo.flv";
        break;
    case 2:
        //Change Video Location
        vidLocation += "myVideo2.flv";
        break;
    case 3:
        //Change Video Location
        vidLocation += "myVideo3.flv";
        break;
    case 4:
        //Change Video Location
        vidLocation += "myVideo4.flv";
        break;
}

//Change value of flashplayer FlashVar
$('#flash').val(vidLocation);
}

视频看起来已正确加载,所有信息似乎都是正确的,但当我点击播放按钮时,视频不会播放(当前视频继续播放)。

加载另一个视频后如何将其加载到 Flash 播放器中?

EDIT2 如果我尝试这样做:

//Creates empty values
var flashvars = vidLocation;
var params = {};
var attributes = {};

//Change video
swfobject.embedSWF("videoplayer.swf", "video_content", "300", "120", "9.0.0", "expressInstall.swf", flashvars, params, attributes);

而不是:

//Change value of flashplayer FlashVar
$('#flash').val(vidLocation);

这似乎现在重新加载播放器,但它仍然无法播放。

Possible Duplicate:
Change flash src with jquery?

EDIT I figured out the first issue (not loading at all) so I took that portion out

I have a flashplayer that I make like so:

<div id="video_content"><div id="flash_wrapper">
                <object classid="MyID" width="402" height="285" id="videoplayer" align="middle">
                    <param name="movie" value="videoplayer.swf" />
                    <param name="quality" value="high" />
                    <param name="bgcolor" value="#000000" />
                    <param name="play" value="true" />
                    <param name="loop" value="true" />
                    <param name="wmode" value="window" />
                    <param name="scale" value="showall" />
                    <param name="menu" value="true" />
                    <param name="devicefont" value="false" />
                    <param name="salign" value="" />
                    <param name="allowScriptAccess" value="sameDomain" />
                    <param name="allowFullScreen" value="true" />
                    <param name="FlashVars" value="screencast_url=myVideo.flv" id="flash" />
                    <!--[if !IE]>-->
                    <object type="application/x-shockwave-flash" data="videoplayer.swf" width="402" height="285">
                        <param name="movie" value="videoplayer.swf" />
                        <param name="quality" value="high" />
                        <param name="bgcolor" value="#000000" />
                        <param name="play" value="true" />
                        <param name="loop" value="true" />
                        <param name="wmode" value="window" />
                        <param name="scale" value="showall" />
                        <param name="menu" value="true" />
                        <param name="devicefont" value="false" />
                        <param name="salign" value="" />
                        <param name="allowScriptAccess" value="sameDomain" />
                        <param name="allowFullScreen" value="true" />
                        <param name="FlashVars" value="screencast_url=myVideo.flv" id="flash" />

                    <!--<![endif]-->
                        <a href="http://www.adobe.com/go/getflash">
                            <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
                        </a>
                    <!--[if !IE]>-->
                    </object>
                    <!--<![endif]-->
                </object>
            </div>

I have buttons that I want to use to change the video playing. The js method to change videos looks like this:

function ChangeVideo(videoIndex) {

//Video Location String
var vidLocation = "screencast_url=";

//Determines what video to load
switch (videoIndex) {
    case 1:
        //Change Video Location
        vidLocation += "myVideo.flv";
        break;
    case 2:
        //Change Video Location
        vidLocation += "myVideo2.flv";
        break;
    case 3:
        //Change Video Location
        vidLocation += "myVideo3.flv";
        break;
    case 4:
        //Change Video Location
        vidLocation += "myVideo4.flv";
        break;
}

//Change value of flashplayer FlashVar
$('#flash').val(vidLocation);
}

The video looks to have loaded correctly and all the information seems to be correct, but the video will not play when I hit the play button (Current video keeps playing).

How would you load another video into a flash player after it has been loaded?

EDIT2 If I try this:

//Creates empty values
var flashvars = vidLocation;
var params = {};
var attributes = {};

//Change video
swfobject.embedSWF("videoplayer.swf", "video_content", "300", "120", "9.0.0", "expressInstall.swf", flashvars, params, attributes);

Instead of :

//Change value of flashplayer FlashVar
$('#flash').val(vidLocation);

Which seems to reload the player now, but it still does not play.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷雾森÷林ヴ 2024-11-14 16:05:56

FlashVars 仅在电影最初加载时加载,因此您无法仅通过更新 DOM 属性来更新视频 url。我建议使用 swfObject 的“动态”加载方法通过 JavaScript 加载新视频。

FlashVars are only loaded when the movie initially loads, so you can't update the video url just by updating the DOM attributes. I recommend using swfObject's "dynamic" loading method to load the new videos via javascript.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文