Changeset 42 for trunk/sl1/wmvplayer.js
- Timestamp:
- 07/17/08 03:17:55 (16 months ago)
- Files:
-
- 1 moved
-
trunk/sl1/wmvplayer.js (moved) (moved from trunk/sl1/player.js) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sl1/wmvplayer.js
r41 r42 1 1 /**************************************************************************** 2 * JW WMV Player version 1. 0, created with M$ Silverlight 1.02 * JW WMV Player version 1.1, created with M$ Silverlight 1.0 3 3 * 4 4 * This file contains all logic for the JW WMV Player. For a functional setup, … … 32 32 this.configuration = { 33 33 backgroundcolor:'FFFFFF', 34 file:'video.wmv', 34 windowless:'false', 35 file:'', 35 36 height:'260', 36 37 image:'', … … 42 43 logo:'', 43 44 overstretch:'false', 44 showicons:'true',45 45 shownavigation:'true', 46 46 showstop:'false', … … 53 53 repeat:'false', 54 54 sender:'', 55 start:'0', 55 56 volume:'90', 56 57 link:'', … … 74 75 height:this.configuration['height'], 75 76 version:'1.0', 76 inplaceInstallPrompt: false,77 isWindowless: 'false',77 inplaceInstallPrompt:true, 78 isWindowless:this.configuration['windowless'], 78 79 background:'#'+this.configuration['backgroundcolor'] 79 80 }, … … 87 88 88 89 jeroenwijering.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 89 98 onLoadHandler: function(pid,tgt,sdr) { 90 99 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 } 95 133 } 96 134 } … … 133 171 setState: function(old,stt) { 134 172 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 } 135 177 }, 136 178 … … 145 187 }, 146 188 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 147 199 setMute: function() { 148 200 if(this.configuration['usemute'] == 'true') { … … 159 211 setPlay: function() { 160 212 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 } 162 218 } else { 163 219 this.model.goStart(); … … 166 222 167 223 setScrub: function(sec) { 168 if(sec < 2) { 224 if(sec < 2) { 169 225 sec = 0; 170 226 } else if (sec > this.configuration['duration']-4) { … … 214 270 jeroenwijering.View = function(cfg,ctr) { 215 271 this.configuration = cfg; 272 this.listeners = Array(); 216 273 this.controller = ctr; 217 274 this.fstimeout; … … 236 293 snd.findName("BufferText").Text = pct; 237 294 } 295 this.delegate('BUFFER',Array(pct)); 238 296 }, 239 297 … … 257 315 } 258 316 this.resizePlayer(); 317 this.delegate('FULLSCREEN'); 259 318 }, 260 319 … … 280 339 var max = snd.findName("TimeSlider").Width; 281 340 snd.findName("DownloadProgress").Width = Math.round(max*pct/100); 341 this.delegate('LOAD',Array(pct)); 282 342 }, 283 343 … … 298 358 snd.findName("MuteIcon").Visibility = "Collapsed"; 299 359 } 360 this.delegate('MUTE'); 300 361 }, 301 362 … … 307 368 snd.findName("PlaySymbol").Visibility = "Collapsed"; 308 369 snd.findName("PlayOffSymbol").Visibility = "Visible"; 309 if (stt=='Playing' || this.configuration['showicons']=='false') {370 if (stt=='Playing') { 310 371 snd.findName("BufferIcon").Visibility = "Collapsed"; 311 372 snd.findName("BufferText").Visibility = "Collapsed"; … … 313 374 snd.findName("MuteIcon").Visibility = "Visible"; 314 375 } 315 } else if(this.configuration['showicons'] == 'true'){376 } else{ 316 377 snd.findName("BufferIcon").Visibility = "Visible"; 317 378 snd.findName("BufferText").Visibility = "Visible"; 318 } else {319 snd.findName("BufferIcon").Visibility = "Collapsed";320 snd.findName("BufferText").Visibility = "Collapsed";321 379 } 322 380 } else { … … 326 384 snd.findName("PlaySymbol").Visibility = "Visible"; 327 385 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()); 332 392 } 333 } 393 } catch (err) {} 394 this.delegate('STATE',Array(old,stt)); 334 395 }, 335 396 … … 338 399 var snd = this.configuration['sender']; 339 400 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)); 349 413 }, 350 414 … … 352 416 var snd = this.configuration['sender']; 353 417 snd.findName("VolumeHighlight").Width = Math.round(pct/5); 418 this.delegate('VOLUME',Array(pct)); 354 419 }, 355 420 … … 420 485 this.configuration['sender'].findName(sld+'Symbol').Fill = 421 486 "#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 } 422 495 }, 423 496 … … 623 696 this.video.Position = jeroenwijering.utils.spanstring(sec); 624 697 } 625 try {626 prr.hideAd();627 } catch (err) {}628 698 }, 629 699 … … 633 703 this.goPause(0); 634 704 this.video.Source = 'null'; 705 this.view.onBuffer(0); 635 706 }, 636 707 … … 660 731 this.goStart(0); 661 732 } else { 733 this.state = 'Completed'; 734 this.view.onState(this.state,'Completed'); 662 735 this.video.Visibility = 'Collapsed'; 663 736 this.preview.Visibility = 'Visible';
