pixelTop我也试过,但是有个问题,我在DW里把层定在某一个位置,比如说是340,但是一运行,看到的层就跑到其他位置,很郁闷,估计是里面的函数控制的具体位置

解决方案 »

  1.   

    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <style type="text/css">
    <!--
    td {  font-size: 12px; color: #FFFFFF}
    a {  color: #CCCCCC; text-decoration: none}
    -->
    </style>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Hide
    function killErrors() {
    return true;
    }
    window.onerror = killErrors;
    // -->
    </SCRIPT>
    <SCRIPT language=JavaScript>
    <!--
    var srcc = window.location;
    srcc = srcc.toString()
    start = srcc.indexOf("?");
    end = srcc.length;
    if (start==-1){
    srcc = "hh.avi"               //////////////////////////////更改
    }if (start!=-1){
    srcc = srcc.substring(start+1,end);
    }//alert(srcc) day=17;
     month=5;
     year=2002;
     hour=18;
        if ( navigator.appName == "Netscape" )
        {
            navigator.plugins.refresh();
            document.write("\x3C" + "applet MAYSCRIPT Code=NPDS.npDSEvtObsProxy.class")
            document.writeln(" width=352 height=288 name=appObs\x3E \x3C/applet\x3E")
        }
    var Player;
    var isplaying;
    var movelen;
    var history;
    var ispause;
    var isstop;
    history=false;
    movelen=0;
    isstop=false;
    isplaying=false;
    ispause=false;
    mute=false;
    Player="document.NSPlay";
    var playfile='';
    function preload(imgname,imgsrc)
    {
    eval(imgname+'=new Image()')
    eval(imgname+'.src="MEDIA\/'+imgsrc+'"')
    }
    preload("play1","play.gif")
    preload("play2","play.gif")
    preload("stop1","stop_b.gif");
    preload("stop2","stop_b.gif");
    preload("sound1","sound.gif");
    preload("sound2","sound.gif");
    preload("volume","volume.gif");
    preload("pause1","pause.gif");
    preload("pause2","pause.gif");
    preload("full1","full.gif");
    preload("full2","full_b.gif");function playy(src){
    var abc
    abc = src + ""
    playhistory(abc)
    }
    function doPlay(){  if(!isplaying){
        if (eval(Player).FileName=='') return;
    eval(Player).Play();
    if (eval(Player).FileName!=filename)
    if(!ispause){   
    movelen=0;
    }
        document.play.src=play2.src;
        document.stop.src=stop1.src;
        document.pause.src=pause1.src;
        isplaying=true;  
        ispause = false;
        isstop=false;
      }
    }    
    function DoStop()
    {
      if(isplaying){
    eval(Player).CurrentPosition=0;
    eval(Player).Stop();
    document.play.src=play1.src;
        document.stop.src=stop2.src;
        document.pause.src=pause1.src;
        if (document.seek.style.visibility=="visible")
          document.seek.style.left=745;
        isstop=true;
        isplaying=false;
        ispause=false;
       } 
    }
    function DoPause()
    {
    if(isplaying){
       eval(Player).Pause();
       isplaying = false
       ispause = true
       isstop=false;
    document.play.src=play1.src;
        document.pause.src=pause2.src;
        document.stop.src=stop1.src;
    }
    }
    function SetPosition(Pos)
    {
    if (!isplaying) return;
    eval(Player).CurrentPosition=+Pos;
    }function SetVolume(Pos)
    {
    eval(Player).volume=Pos;
    }function SetMute()
    {
    if (!isplaying) return

    if (mute){
    eval(Player).Mute=false
        document.sound.src=sound1.src;     
        document.vol.style.visibility="visible";
        mute=false
    }
    else{
      eval(Player).Mute=true;
      document.sound.src=sound2.src;
      document.vol.style.visibility="hidden";
      mute=true
    }  
    }
    function GetLength()
    {
    return eval(Player).Duration;
    }
    function GetPosition()
    {
    tt=eval(Player).CurrentPosition
    return tt;
    }
    function SetSource(srcname)
    {
    if (srcname==filename){
      history=false;
      //eval(Player).AutoRewind=true;
      document.seek.style.visibility="hidden";
     } 
     else{
      document.seek.style.visibility="visible"; 
      //eval(Player).AutoRewind=false;
      history=true
     } 
    eval(Player).FileName=srcname;
    document.play.src=play2.src;
        document.stop.src=stop1.src;
        isplaying=true;
    }
    function SetWH(widthpx,heightpx)
    {
    eval(Player).width=widthpx
    eval(Player).height=heightpx
    }
    function SetDisplaySize(setting)
    {
    if (isplaying)
         eval(Player).DisplaySize=setting
    //全屏 setting=3
    //100% setting=0
    // 50% setting=1
    //200% setting=2 
    }
                
    var y,theImg;var Maxvol, Minvol
    Maxvol=338;
    Minvol=303;
    cur=303;
    function move(){
      if (event.button==1&&isplaying){
        left=temp1+event.clientY-y
          
        if ((left<=Maxvol)&&(left>=Minvol))
          theImg.style.pixelTop=left
         else 
           if(left>Maxvol) 
             theImg.style.pixelTop=Maxvol
             else
               theImg.style.pixelTop=Minvol 
       // document.form1.pos.value=theImg.style.pixelTop
      return false
      }
    }
    function enddrag(){
      
     //这里设置音量
     if (isplaying){
       cur=theImg.style.pixelTop;
       cur=Math.floor((Maxvol-cur)/(Maxvol-Minvol)*(-2000)); 
       SetVolume(cur);
       document.onmousemove=null;
      } }
    function begindrag(Elm){
      if (!document.all)
        return
      if (!isplaying)
        return   
      temp1=Elm.style.pixelTop   
      theImg=Elm
      y=event.clientY;
      document.onmousemove=move     
    }
      

  2.   

    var Start, End;
    var seeking;
    seeking=falseStart=345;
    End=390;
    function beginseek(Elm){
      if (!document.all)
        return
      if (!isplaying)
        return   
      temp1=Elm.style.pixelTop   
      theImg=Elm
      y=event.clientY;
      seeking=true
      document.onmousemove=moveseek     
    }function moveseek(){
      if (event.button==1&&isplaying){
        left=temp1+event.clientY-y
          
        if ((left<=End)&&(left>=Start))
          theImg.style.pixelTop=left
         else 
           if(left>End) 
             theImg.style.pixelTop=End
             else
               theImg.style.pixelTop=Start 
       // document.form1.pos.value=theImg.style.pixelTop
      return false
      }
    }function enddragseek()
    {
      
     //这里设置时间搜索
     if (isplaying)
     {
       movelen=GetLength()
       cur=theImg.style.pixelTop;
       if (cur==End)
         DoStop();
       else
       {  
         cur=Math.floor((cur-Start)*movelen/(End-Start)); 
         SetPosition(cur);
         seeking=false;
         document.onmousemove=null;
        } 
      } }function changeseek(){
      if (eval(Player).PlayState!=2) return;
      if (!history) return;
      if (!seeking){
        if (movelen==0)
          movelen=GetLength();  
        cur=GetPosition();
        cur=Math.floor((End-Start)*cur/movelen);
        document.seek.style.pixelTop=Start+cur;
      }  
      //alert(isplaying+''+history);
      setTimeout("changeseek()",1000);
        
       //} 
      
      
    }function playhistory(src){
      SetSource(src);  
    }
    function showchoose() 

     if (document.all.menu1.style.display=="none") 
      document.all.menu1.style.display="block"; 
      else 
      {
      playhistory(document.formdisco.getyy.value+document.formdisco.getmm.value+document.formdisco.getdd.value+".wmv")
      document.all.menu1.style.display="none"; 
      }
    } //-->
    </SCRIPT><SCRIPT event="PlayStateChange(lOldState, lNewState)" for=NSPlay 
    language=JScript>
        if (lNewState==2){
          movelen=GetLength();      
          changeseek();
        }      </SCRIPT><SCRIPT event=EndOfStream(lResult) for=NSPlay language=JScript>
        DoStop()    
    </SCRIPT>
    </head>
    <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" onLoad=playhistory(srcc)>
    <IMG 
    alt=时间调节(Time) height=11 id=seek name=seek onmousedown=beginseek(document.seek) 
    onmouseup=enddragseek() src="MEDIA/course_button.gif" style="CURSOR: hand; LEFT: 343px; POSITION: absolute; TOP: 371px; VISIBILITY: visible; width: 11px; height: 7px;" width=15> 
    <table width="361" border="0" height="211" cellpadding="0" cellspacing="0"  background="images/shipin_bg.jpg">
      <tr>
        <TD width="21" height="211"></TD>
        <TD width="274" height="211" valign="middle" align="center">
    <object classid=CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95 
                codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 
                height=200 id=NSPlay type=application/x-oleobject width=270 
                viewastext standby="加载 Microsoft Windows Media Player 组件...">
            <param name="FileName" value="">
            <param name="AutoStart" value="true">
            <param name="AutoRewind" value="-1">
            <param name="AnimationAtStart" value="false">
            <param name="ShowControls" value="false">
            <param name="ClickToPlay" value="false">
            <param name="EnableContextMenu" value="true">
            <param name="EnablePositionControls" value="false">
            <param name="Balance" value="0">
            <param name="ShowStatusBar" value="false">
            <param name="AutoSize" value="0">
            <embed 
                type="application/x-mplayer2" 
                pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" 
                filename src  autostart="false" 
    enablecontextmenu="false" 
    clicktoplay="false"   
    enablepositioncontrols="false"                
                showcontrols="0" showstatusbar="1"                
                showdisplay="0"                width="270" height="216"> </embed> 
          </object></TD>
        <td width="66" valign="middle">
    <table width="90%"  border="0">
            <tr> 
              <td width="77%" align="center"> <div></div>
                <a href="#" onClick=Javascript:doPlay()><img alt=播放 border=0 height=16 
                name=play src="MEDIA/play.gif" width=24></a></td>
              <td width="23%" align="center" valign="bottom"><img src="MEDIA/55.gif" width="11" height="11" border="0" alt="播放进度"></td>
            </tr>
            <tr> 
              <td align="center"><a href="#" onClick=Javascript:DoStop()><img alt=停止播放 border=0 height=16 
                name=stop src="MEDIA/stop_b.jpg" width=24></a></td>
              <td rowspan="3" align="center" valign="top"><img src="MEDIA/course.gif" width="11" height="42"></td>
            </tr>
            <tr> 
              <td align="center"><a href="#" onClick=DoPause()><img src="MEDIA/pause.jpg" alt="暂停播放" name=pause width="24" height="16" border="0"></a></td>
            </tr>
            <tr> 
              <td align="center"><a  onClick=SetDisplaySize(3)><img src="MEDIA/full.jpg" alt="全屏显示" name=full width="24" height="16" border="0" style="cursor:hand"></a></td>
            </tr>
            <tr> 
              <td align="center"><img src="MEDIA/5.gif" width="24" height="16" alt="插件下载" border="0"></td>
              <td align="center" valign="bottom"><img src="MEDIA/sound.gif" width="11" height="11" alt="播放音量"></td>
            </tr>
            <tr> 
              <td align="center"> <div><img src="MEDIA/6.jpg" width="24" height="16" alt="视频投票" border="0"></div></td>
              <td align="center" valign="top"><img src="MEDIA/volume.gif"></td>
            </tr>
          </table></td>
      </tr>
    </table> <IMG alt=音量调节(volume) height=11 id=vol name=vol onmousedown=begindrag(document.vol) onmouseup=enddrag() src="MEDIA/sound_button.gif" style="CURSOR: hand; LEFT: 338px; POSITION: absolute; TOP: 120px; visibility: visible" width=8> 
    <SCRIPT language=JavaScript>
    cur=Math.floor((Maxvol-cur)/(Maxvol-Minvol)*(-2000));  
    SetVolume(cur); 
    playfile=''; 
    var filename='live.wmv '
    if (playfile!=''){ 
      SetSource(filename);  

    </SCRIPT>
     
    </body>
    </html>
    ===================================================
    我把原代码帖出来,希望大家帮帮我,更改里面的avi的地址就可以播放视频