导读:
效果和GOOGLE的一样,只是具体实现方式有点不一样,各有利弊。
这里定义了一个Player类,并实现了一些简单的控制方法,有兴趣的可以自己扩展
// JavaScript Player// Author:Radish(Robin Chen) QQ:4705648 MSN:robchen@126.com EMAIL:robchen@126.comfunction Player(movieClips,interval,containter){
var uniqueID = Math.round(Math.random()*1000);
while(window[uniqueID]){
uniqueID ++ } this.uniqueID = uniqueID;
this.timeLine = movieClips;
this.containter = containter;
this.interval = interval;
this.currentFrame = 0 this.playMode = 0}Player.prototype = {
play:function(){
if(this.currentFrame >= this.timeLine.length){
this.currentFrame = this.timeLine.length - 1 this.stop();
return }else if(this.currentFrame < 0){
this.currentFrame = 0 this.stop();
return } this.showMovie();
if(this.playMode == 0){
this.currentFrame ++ }else{
this.currentFrame -- } var _this = this window[this.uniqueID] = window.setTimeout(function(){_this.play();},this.interval);
},
stop:function(){
window.clearTimeout(window[this.uniqueID]);
},
gotoAndStop:function(frame){
if(frame < 0)frame = this.timeLine.length + frame;
frame = (frame >=this.timeLine.length)?this.timeLine.length-1:frame;
this.currentFrame = frame;
this.showMovie();
this.stop();
},
gotoAndPlay:function(frame){
if(frame < 0)frame = this.timeLine.length + frame;
frame = (frame > this.timeLine.length)?this.timeLine.length:frame;
this.currentFrame = frame;
this.showMovie();
this.play();
},
showMovie:function(){
if(this.containter.tagName.toLowerCase() == "img"){
this.containter.src = this.timeLine[this.currentFrame].src;
}else{
this.containter.style.backgroundImage = this.timeLine[this.currentFrame].src;
} }}
本文效果的演示地址如下:
http://www.robchen.cn/jsplayer/
GOOGLE的效果演示:
http://www.google.co.kr/ig?sp=korea&hl=ko
Trackback: http://tb.blog.youkuaiyun.com/TrackBack.aspx?PostId=1636293
本文转自
http://blog.youkuaiyun.com/rob123/archive/2007/06/03/1636293.aspx
效果和GOOGLE的一样,只是具体实现方式有点不一样,各有利弊。
这里定义了一个Player类,并实现了一些简单的控制方法,有兴趣的可以自己扩展
// JavaScript Player// Author:Radish(Robin Chen) QQ:4705648 MSN:robchen@126.com EMAIL:robchen@126.comfunction Player(movieClips,interval,containter){
var uniqueID = Math.round(Math.random()*1000);
while(window[uniqueID]){
uniqueID ++ } this.uniqueID = uniqueID;
this.timeLine = movieClips;
this.containter = containter;
this.interval = interval;
this.currentFrame = 0 this.playMode = 0}Player.prototype = {
play:function(){
if(this.currentFrame >= this.timeLine.length){
this.currentFrame = this.timeLine.length - 1 this.stop();
return }else if(this.currentFrame < 0){
this.currentFrame = 0 this.stop();
return } this.showMovie();
if(this.playMode == 0){
this.currentFrame ++ }else{
this.currentFrame -- } var _this = this window[this.uniqueID] = window.setTimeout(function(){_this.play();},this.interval);
},
stop:function(){
window.clearTimeout(window[this.uniqueID]);
},
gotoAndStop:function(frame){
if(frame < 0)frame = this.timeLine.length + frame;
frame = (frame >=this.timeLine.length)?this.timeLine.length-1:frame;
this.currentFrame = frame;
this.showMovie();
this.stop();
},
gotoAndPlay:function(frame){
if(frame < 0)frame = this.timeLine.length + frame;
frame = (frame > this.timeLine.length)?this.timeLine.length:frame;
this.currentFrame = frame;
this.showMovie();
this.play();
},
showMovie:function(){
if(this.containter.tagName.toLowerCase() == "img"){
this.containter.src = this.timeLine[this.currentFrame].src;
}else{
this.containter.style.backgroundImage = this.timeLine[this.currentFrame].src;
} }}
本文效果的演示地址如下:
http://www.robchen.cn/jsplayer/
GOOGLE的效果演示:
http://www.google.co.kr/ig?sp=korea&hl=ko
Trackback: http://tb.blog.youkuaiyun.com/TrackBack.aspx?PostId=1636293
本文转自
http://blog.youkuaiyun.com/rob123/archive/2007/06/03/1636293.aspx
本文介绍了一个简单的自制播放器实现方案,通过定义Player类并实现控制方法来模拟播放效果。该播放器支持基本的播放、暂停及跳转等功能。
971

被折叠的 条评论
为什么被折叠?



