Changeset 42 for trunk/sl1/wmvplayer.js

Show
Ignore:
Timestamp:
07/17/08 03:17:55 (16 months ago)
Author:
jeroen
Message:

tagged the 1.1 wmvplayer and started the air player

Files:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sl1/wmvplayer.js

    r41 r42  
    11/**************************************************************************** 
    2 * JW WMV Player version 1.0, created with M$ Silverlight 1.0 
     2* JW WMV Player version 1.1, created with M$ Silverlight 1.0 
    33* 
    44* This file contains all logic for the JW WMV Player. For a functional setup, 
     
    3232        this.configuration = { 
    3333                backgroundcolor:'FFFFFF', 
    34                 file:'video.wmv', 
     34                windowless:'false', 
     35                file:'', 
    3536                height:'260', 
    3637                image:'', 
     
    4243                logo:'', 
    4344                overstretch:'false', 
    44                 showicons:'true', 
    4545                shownavigation:'true', 
    4646                showstop:'false', 
     
    5353                repeat:'false', 
    5454                sender:'', 
     55                start:'0', 
    5556                volume:'90', 
    5657                link:'', 
     
    7475                        height:this.configuration['height'], 
    7576                        version:'1.0', 
    76                         inplaceInstallPrompt:false, 
    77                         isWindowless:'false', 
     77                        inplaceInstallPrompt:true, 
     78                        isWindowless:this.configuration['windowless'], 
    7879                        background:'#'+this.configuration['backgroundcolor'] 
    7980                }, 
     
    8788 
    8889jeroenwijering.Player.prototype = { 
     90        addListener: function(typ,fcn) { 
     91                this.view.listeners.push({type:typ,func:fcn}); 
     92        }, 
     93 
     94        getConfig: function() {  
     95                return this.configuration; 
     96        }, 
     97 
    8998        onLoadHandler: function(pid,tgt,sdr) { 
    9099                tgt.configuration['sender'] = sdr; 
    91                 this.controller = new jeroenwijering.Controller(tgt.configuration); 
    92                 this.view = new jeroenwijering.View(tgt.configuration,this.controller); 
    93                 this.model = new jeroenwijering.Model(tgt.configuration,this.controller,this.view); 
    94                 this.controller.startMVC(this.view,this.model); 
     100                tgt.controller = new jeroenwijering.Controller(tgt.configuration); 
     101                tgt.view = new jeroenwijering.View(tgt.configuration,tgt.controller); 
     102                tgt.model = new jeroenwijering.Model(tgt.configuration,tgt.controller,tgt.view); 
     103                tgt.controller.startMVC(tgt.view,tgt.model); 
     104        }, 
     105 
     106        sendEvent: function(typ,prm) { 
     107                switch(typ.toUpperCase()) { 
     108                        case 'LINK': 
     109                                this.controller.setLink(); 
     110                                break; 
     111                        case 'LOAD': 
     112                                this.controller.setLoad(prm); 
     113                                break; 
     114                        case 'MUTE': 
     115                                this.controller.setMute(); 
     116                                break; 
     117                        case 'PLAY': 
     118                                this.controller.setPlay(); 
     119                                break; 
     120                        case 'SCRUB': 
     121                                this.controller.setScrub(prm); 
     122                                break; 
     123                        case 'STOP': 
     124                                this.controller.setStop(); 
     125                                break; 
     126                        case 'VOLUME': 
     127                                this.controller.setVolume(prm); 
     128                                break; 
     129                        case 'FULLSCREEN': 
     130                                this.controller.setFullscreen(); 
     131                                break; 
     132                } 
    95133        } 
    96134} 
     
    133171        setState: function(old,stt) { 
    134172                this.state = stt; 
     173                var pos = this.configuration['start']; 
     174                if(old == 'Closed' && pos > 0) { 
     175                        setTimeout(jeroenwijering.utils.delegate(this,this.setScrub),200,pos); 
     176                }  
    135177        }, 
    136178 
     
    145187        }, 
    146188 
     189        setLoad: function(fil) { 
     190                if(this.model.state != "Closed") { 
     191                        this.model.goStop();  
     192                } 
     193                this.configuration['file'] = fil; 
     194                if(this.configuration['autostart'] == 'true') { 
     195                        setTimeout(jeroenwijering.utils.delegate(this.model,this.model.goStart),100); 
     196                } 
     197        }, 
     198 
    147199        setMute: function() { 
    148200                if(this.configuration['usemute'] == 'true') { 
     
    159211        setPlay: function() { 
    160212                if(this.state == 'Buffering' || this.state == 'Playing') { 
    161                         this.model.goPause(); 
     213                        if(this.configuration['duration'] == 0) {  
     214                                this.model.goStop(); 
     215                        } else {  
     216                                this.model.goPause(); 
     217                        } 
    162218                } else { 
    163219                        this.model.goStart(); 
     
    166222 
    167223        setScrub: function(sec) { 
    168                 if(sec < 2) {  
     224                if(sec < 2) { 
    169225                        sec = 0; 
    170226                } else if (sec > this.configuration['duration']-4) { 
     
    214270jeroenwijering.View = function(cfg,ctr) { 
    215271        this.configuration = cfg; 
     272        this.listeners = Array(); 
    216273        this.controller = ctr; 
    217274        this.fstimeout; 
     
    236293                        snd.findName("BufferText").Text = pct; 
    237294                } 
     295                this.delegate('BUFFER',Array(pct)); 
    238296        }, 
    239297 
     
    257315                } 
    258316                this.resizePlayer(); 
     317                this.delegate('FULLSCREEN'); 
    259318        }, 
    260319 
     
    280339                var max = snd.findName("TimeSlider").Width; 
    281340                snd.findName("DownloadProgress").Width = Math.round(max*pct/100); 
     341                this.delegate('LOAD',Array(pct)); 
    282342        }, 
    283343 
     
    298358                        snd.findName("MuteIcon").Visibility = "Collapsed"; 
    299359                } 
     360                this.delegate('MUTE'); 
    300361        }, 
    301362 
     
    307368                        snd.findName("PlaySymbol").Visibility = "Collapsed"; 
    308369                        snd.findName("PlayOffSymbol").Visibility = "Visible"; 
    309                         if (stt=='Playing' || this.configuration['showicons']=='false') { 
     370                        if (stt=='Playing') { 
    310371                                snd.findName("BufferIcon").Visibility = "Collapsed"; 
    311372                                snd.findName("BufferText").Visibility = "Collapsed"; 
     
    313374                                        snd.findName("MuteIcon").Visibility = "Visible"; 
    314375                                } 
    315                         } else if(this.configuration['showicons'] == 'true') { 
     376                        } else{ 
    316377                                snd.findName("BufferIcon").Visibility = "Visible"; 
    317378                                snd.findName("BufferText").Visibility = "Visible"; 
    318                         } else { 
    319                                 snd.findName("BufferIcon").Visibility = "Collapsed"; 
    320                                 snd.findName("BufferText").Visibility = "Collapsed"; 
    321379                        } 
    322380                } else {  
     
    326384                        snd.findName("PlaySymbol").Visibility = "Visible"; 
    327385                        snd.findName("PlayOffSymbol").Visibility = "Collapsed"; 
    328                         if(this.configuration['showicons'] == 'true') { 
    329                                 snd.findName("PlayIcon").Visibility = "Visible"; 
    330                         } else { 
    331                                 snd.findName("PlayIcon").Visibility = "Collapsed"; 
     386                        snd.findName("PlayIcon").Visibility = "Visible"; 
     387                } 
     388                try { 
     389                        if(!(old == 'Completed' && stt == 'Buffering') && 
     390                                !(old == 'Buffering' && stt == 'Paused')) { 
     391                                playerStatusChange(old.toUpperCase(),stt.toUpperCase()); 
    332392                        } 
    333                 } 
     393                } catch (err) {} 
     394                this.delegate('STATE',Array(old,stt)); 
    334395        }, 
    335396 
     
    338399                var snd = this.configuration['sender']; 
    339400                var max = snd.findName("TimeSlider").Width; 
    340                 var pos = Math.round(max*elp/dur); 
    341                 if(isNaN(pos)) { pos = 0; } 
    342                 this.configuration['duration'] = dur; 
    343                 snd.findName("ElapsedText").Text =  
    344                         jeroenwijering.utils.timestring(elp); 
    345                 snd.findName("RemainingText").Text =  
    346                         jeroenwijering.utils.timestring(dur-elp); 
    347                 snd.findName("TimeSymbol")['Canvas.Left'] = pos+4; 
    348                 snd.findName("TimeHighlight").Width = pos-2; 
     401                if(dur > 0) { 
     402                        var pos = Math.round(max*elp/dur); 
     403                        this.configuration['duration'] = dur; 
     404                        snd.findName("ElapsedText").Text = jeroenwijering.utils.timestring(elp); 
     405                        snd.findName("RemainingText").Text = jeroenwijering.utils.timestring(dur-elp); 
     406                        snd.findName("TimeSymbol").Visibility = "Visible"; 
     407                        snd.findName("TimeSymbol")['Canvas.Left'] = pos+4; 
     408                        snd.findName("TimeHighlight").Width = pos-2; 
     409                } else  {  
     410                        snd.findName("TimeSymbol").Visibility = "Collapsed"; 
     411                } 
     412                this.delegate('TIME',Array(elp,dur)); 
    349413        }, 
    350414 
     
    352416                var snd = this.configuration['sender']; 
    353417                snd.findName("VolumeHighlight").Width = Math.round(pct/5); 
     418                this.delegate('VOLUME',Array(pct)); 
    354419        }, 
    355420 
     
    420485                this.configuration['sender'].findName(sld+'Symbol').Fill =  
    421486                        "#FF"+this.configuration['frontcolor']; 
     487        }, 
     488 
     489        delegate: function(typ,arg) { 
     490                for(var i=0; i<this.listeners.length; i++) { 
     491                        if(this.listeners[i]['type'].toUpperCase() == typ) { 
     492                                this.listeners[i]['func'].apply(null,arg); 
     493                        } 
     494                } 
    422495        }, 
    423496 
     
    623696                        this.video.Position = jeroenwijering.utils.spanstring(sec); 
    624697                } 
    625                 try {  
    626                         prr.hideAd(); 
    627                 } catch (err) {} 
    628698        }, 
    629699 
     
    633703                this.goPause(0); 
    634704                this.video.Source = 'null'; 
     705                this.view.onBuffer(0); 
    635706        }, 
    636707 
     
    660731                        this.goStart(0); 
    661732                } else { 
     733                        this.state = 'Completed'; 
     734                        this.view.onState(this.state,'Completed'); 
    662735                        this.video.Visibility = 'Collapsed'; 
    663736                        this.preview.Visibility = 'Visible';