本帖最后由 qqSuQi 于 2014-11-29 15:40:09 编辑

解决方案 »

  1.   

    加载播放器页面代码<!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>SWF播放器</title>
    <script type="text/javascript" src="/jquery.js"></script>
    <script type="text/javascript">
    function readCookie(name)
    {
        var cookieValue = "";
        var search = name + "=";
        if(document.cookie.length > 0)
        {
            offset = document.cookie.indexOf(search);
            if (offset != -1)
            {
                offset += search.length;
                end = document.cookie.indexOf(";", offset);
                if (end == -1) end = document.cookie.length;
                cookieValue = unescape(document.cookie.substring(offset, end))
            }
        }
        return cookieValue;
    }
    function writeCookie(name, value, hours)
    {
        var expire = "";
        if(hours != null)
        {
            expire = new Date((new Date()).getTime() + hours * 3600000);
            expire = "; expires=" + expire.toGMTString();
        }
        document.cookie = name + "=" + escape(value) + ";path=/" + expire;
    }
    function request(paras) {
        var url = location.href;
        var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
        var paraObj = {}
        for (i = 0; j = paraString[i]; i++) {
            paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
        }
        var returnValue = paraObj[paras.toLowerCase()];
        if (typeof(returnValue) == "undefined") {
            return "";
        } else {
            return returnValue;
        }
    }
    prev_flash_href = request("preurl");
    next_flash_href = request("nexturl");
    flash_url = request("flashurl");
    function addswf()
    {
        w=1038;
        h=480;
        document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" name="top10movie1" width="'+w+'" height="'+h+'" id="flashid1"><param name="wmode" value="opaque"><param name="movie" value="'+flash_url+'"><param name="quality" value="high"><param name="menu" value="false"><embed src="'+flash_url+'" width="'+w+'" height="'+h+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" id="flashid2" name="top10movie2" menu="false" wmode="opaque"></embed></object>');}function GetflashMovieObject(movieName) {
        if (window.document[movieName]) {
            return window.document[movieName]
        }
        if (navigator.appName.indexOf("Microsoft Internet") == -1) {
            if (document.embeds && document.embeds[movieName]) return document.embeds[movieName]
        } else {
            return document.getElementById(movieName)
        }
    }function fortime(i)
    {
        s=Math.floor(i/60);
        m=Math.ceil(i-(s*60));
        if(m==60){m=0;s++;}
        if(m<=9)m="0"+m;
        return ""+s+":"+m;
    }
    $(document).ready(function(){    //循环播放缓存读取
        if(readCookie("play_model")==1) $(".flash_loop").addClass('flash_loop2');
        else $(".flash_loop").removeClass('flash_loop2');    if(readCookie("play_model")==1) $(".flash_way").html("单曲循环重复播放");
        else if(readCookie("play_model")==2) $(".flash_way").html("自动播放上一曲");
        else $(".flash_way").html("自动播放下一曲");
        $(".flash_loop").click(function(){
            if($(this).is('.flash_loop2')) {
                writeCookie("play_model", 3, 200);
                $(".flash_way").html("自动播放下一曲");
                $(this).removeClass('flash_loop2');
            } else {
                writeCookie("play_model", 1, 200);
                $(".flash_way").html("单曲循环重复播放");
                $(this).addClass('flash_loop2');
            }    })
        $(".flash_play").click(function () {
            if(swf_flashcontrol_target.IsPlaying()) {
                swf_flashcontrol_target.StopPlay();
                $(this).addClass("flash_play2");
            } else {
                swf_flashcontrol_target.Play();
                $(this).removeClass("flash_play2");
            }
        });
        //重播按钮
        $("#swfcontrolbox_butons>div").eq(2).click(function () {
            swf_flashcontrol_target.Rewind();
            swf_flashcontrol_target.Play()
        })
        $(".player_infobtn>dl").eq(0).click(function () {
            swf_flashcontrol_target.Rewind();
            swf_flashcontrol_target.Play()
        })
        if (!-[1,]) swf_flashcontrol_target = GetflashMovieObject("flashid1");
        else swf_flashcontrol_target = GetflashMovieObject("flashid2");
        enditflash = false;
        swf_zs=0;    last_currentFrame=0;    $(".flash_stauts").click(function(e){
            s=e.pageX-$(this).position().left;
            s=s/658;
            swf_flashcontrol_target.GotoFrame(s * swf_flashcontrol_target.TGetProperty("/", 5));
            swf_flashcontrol_target.Play();
        })    plash_timer1 = window.setInterval(function () {
            if (!enditflash) {
                $(".flash_scroll").css("width", swf_flashcontrol_target.PercentLoaded() *600 / 100);            if (swf_flashcontrol_target.PercentLoaded() == 100) {
                    enditflash = true;
                    swf_flashcontrol_target.Play();
                }        } else {
                if (!-[1,]) {
                    TotalFrames = swf_flashcontrol_target.TotalFrames;
                    currentFrame = parseInt(swf_flashcontrol_target.CurrentFrame()) + 1;
                }
                else {
                    TotalFrames = swf_flashcontrol_target.TGetProperty("/", 5);
                    currentFrame = parseInt(swf_flashcontrol_target.TGetProperty("/", 4));            }
                if(last_currentFrame>0 && swf_zs==0){swf_zs=currentFrame-last_currentFrame;}
                last_currentFrame=currentFrame;
                if(swf_zs!=0)$(".flash_time").html(fortime(currentFrame/swf_zs/10)+"/"+fortime(TotalFrames/swf_zs/10));
                PercentLoadeds = (currentFrame + 1) / TotalFrames * 100;
                $(".flash_scroll").css("width", PercentLoadeds * 600 / 100);
                if (Math.floor(PercentLoadeds) >= 100) {
    if(TotalFrames>20){

                    play_model=readCookie("play_model");
                    if(play_model==1) {
                        swf_flashcontrol_target.StopPlay()
                        swf_flashcontrol_target.Rewind()
                        swf_flashcontrol_target.Play();
                    }
                    else if (play_model==2) {
                        swf_flashcontrol_target.StopPlay()
                        window.clearInterval(plash_timer1);
                        window.parent.location.href=request("preurl");
                    }
                    else{
                        window.clearInterval(plash_timer1);
                        swf_flashcontrol_target.StopPlay()
                        window.parent.location.href=request("nexturl");
                    }

    }
                }
            }
        }, 100);
        $(".flash_play0").click(function(){window.parent.location.href=request("preurl")})
        $(".flash_play1").click(function(){window.parent.location.href=request("nexturl");})
      /*  $(".flash_full").click(function(){
            swf_flashcontrol_target.StopPlay();
            $('.flash_play').addClass("flash_play2");
            window.open('/FullPlay.html?url='+base64encode(base64encode(base64encode(flash_url.replace('','')))));
        });
    */
    })
    </script>
    </head>
    <body>
    <div class="main">
        <div class="fplay"><script>addswf()</script></div>
        <div class="flash_contrl">
            <a class="flash_play0" href="javascript:void(0);"><span>上一首</span></a>
            <a class="flash_play" href="javascript:void(0);"><span>暂停/播放</span></a>
            <a class="flash_play1" href="javascript:void(0);"><span>下一首</span></a>
    <div class="flash_stauts"><em></em><div class="flash_scroll"></div></div>
            <div class="flash_time"></div>
            <div class="flash_way"></div>
            <a class="flash_loop" href="javascript:void(0);"><span>控制播放</span></a>
            <a class="flash_full" href="javascript:void(0);"><span>全屏播放</span></a>
        </div>
    </div>
    </body>
    </html>问题:从其他网站扒来的FLASH播放器可控制代码,测试出现调用外部SWF文件播放时,控制进度条,暂停等功能失效
    具体如下//addswf('http://abc.com/1.swf');  //调用abc.com的SWF文件,在abc.com域名下不可控制(错误)
    //addswf('http://127.0.0.2/1.swf'); //调用127.2的SWF文件,在127.1域名下不可控制(错误)
    // addswf('http://127.0.0.1/1.swf');  //调用127.1的SWF文件,在abc.com域名下不可控制(错误) addswf('http://127.0.0.1/1.swf');  //调用127.1的SWF文件,在127.1域名下可正常控制求大神帮看下什么原因,急,在线等,
    如果解决比较困难,可有偿。
    本人小白,弄了一天,都没看出问题在那