StartPlayer.js
上传用户:wenllgg125
上传日期:2020-04-09
资源大小:7277k
文件大小:6k
源码类别:

SCSI/ASPI

开发平台:

Others

  1. function StartPlayer_0(parentId, playerWidth, playerHeight, mediaUrl, forumPath) {
  2. playerWidth = parseInt(playerWidth);
  3. playerHeight = parseInt(playerHeight);
  4. var xmal = 'silverlight/player/player.xaml';
  5. if (mediaUrl.indexOf('.mp3') > 0 || mediaUrl.indexOf('.wma') > 0 || mediaUrl.indexOf('.wav') > 0){
  6. xmal = 'silverlight/player/audio.xaml';
  7. playerHeight = 33;
  8. }
  9.     this._hostname = EmePlayer.Player._getUniqueName("xamlHost");
  10.   
  11.     Silverlight.createObjectEx( { source: (typeof(forumpath) == 'undefined' ? '/' : forumpath) + xmal, 
  12.                   parentElement: $get(parentId ||"divPlayer_0"), 
  13.                   id:this._hostname, 
  14.                   properties:{
  15.                   
  16.                    width: ((typeof playerWidth == 'undefined')||playerWidth > 800 ? 400 : playerWidth).toString(), 
  17.                    height:((typeof playerHeight == 'undefined')||playerHeight > 800 ? 300 : playerHeight).toString(),
  18.                    
  19.                    
  20.                     version:'1.0', background:'transparent', isWindowless:'true' }, 
  21.                   events:{ 
  22. onLoad:Function.createDelegate(this, function(){
  23. this._handleLoad();
  24. var mediainfo = { "mediaUrl": mediaUrl,
  25.                       "placeholderImage": "",
  26.                       "chapters": [] };
  27. this._player.set_mediainfo(mediainfo);
  28. }) } } );
  29. }
  30. StartPlayer_0.prototype= {
  31. _handleLoad: function() {
  32. //process the UI liuq
  33.     this.slPlugin = document.getElementById(this._hostname);
  34. if(this.slPlugin.width<260){
  35.      this.slPlugin.width=260;
  36.     }
  37.     if(this.slPlugin.height<33){
  38.      this.slPlugin.height=33;
  39.     }
  40. this.slPlugin_Width=this.slPlugin.width;
  41. this.slPlugin_Height=this.slPlugin.height;
  42. //alert("Player Init:"+this.slPlugin_Width+":"+this.slPlugin_Height);    
  43. this.slPlugin.content.findName("Main").Width=this.slPlugin_Width;
  44. this.slPlugin.content.findName("Main").Height=this.slPlugin_Height;
  45. this.slPlugin.content.findName("VideoBackground").Width=this.slPlugin_Width;
  46. this.slPlugin.content.findName("VideoBackground").Height=this.slPlugin_Height-this.slPlugin.content.findName("PlayerControls").Height;
  47. this.slPlugin.content.findName("VideoWindow").Width=this.slPlugin_Width;
  48. this.slPlugin.content.findName("PlayerControls")["Canvas.Top"]=this.slPlugin_Height-this.slPlugin.content.findName("PlayerControls").Height;
  49. this.slPlugin.content.findName("VideoWindow").Height=this.slPlugin_Height-this.slPlugin.content.findName("PlayerControls").Height;
  50. this.slPlugin.content.findName("BarBackground").Width=this.slPlugin_Width;
  51. this.slPlugin.content.findName("RightControls")["Canvas.Left"]=this.slPlugin_Width-this.slPlugin.content.findName("RightControls").Width;
  52. this.slPlugin.content.findName("TimeSlider").Width=this.slPlugin_Width-this.slPlugin.content.findName("RightControls").Width-65;
  53. this.slPlugin.content.findName("DownloadProgressSlider").Width=this.slPlugin_Width-this.slPlugin.content.findName("RightControls").Width-65;
  54.         this._player = $create(   ExtendedPlayer.Player, 
  55.                                   { // properties
  56.                                     autoPlay    : true, 
  57.                                     volume      : 1.0,
  58.                                     muted       : false
  59.                                   
  60.                                   }, 
  61.                                   { // event handlers
  62.                                     mediaEnded: Function.createDelegate(this, this._onMediaEnded)
  63.                                   },
  64.                                   null, $get(this._hostname)  ); 
  65. //Process Button Mouse Interaction
  66.         
  67. this.slPlugin.content.findName("PlayPauseButton").addEventListener("MouseEnter", Function.createDelegate(this, function(){this.slPlugin.content.findName('PlayPauseButton_FocusInAnimation').begin()}));
  68. this.slPlugin.content.findName("PlayPauseButton").addEventListener("MouseLeave", Function.createDelegate(this, function(){this.slPlugin.content.findName('PlayPauseButton_FocusOutAnimation').begin()}));
  69. this.slPlugin.content.findName("TimeThumb").addEventListener("MouseEnter", Function.createDelegate(this, function(){this.slPlugin.content.findName('TimeThumb_FocusInAnimation').begin()}));
  70. this.slPlugin.content.findName("TimeThumb").addEventListener("MouseLeave", Function.createDelegate(this, function(){this.slPlugin.content.findName('TimeThumb_FocusOutAnimation').begin()}));
  71. this.slPlugin.content.findName("MuteButton").addEventListener("MouseEnter", Function.createDelegate(this, function(){this.slPlugin.content.findName('MuteButton_FocusInAnimation').begin()}));
  72. this.slPlugin.content.findName("MuteButton").addEventListener("MouseLeave", Function.createDelegate(this, function(){this.slPlugin.content.findName('MuteButton_FocusOutAnimation').begin()}));
  73.    
  74. this.slPlugin.content.findName("VolumeThumb").addEventListener("MouseEnter", Function.createDelegate(this, function(){this.slPlugin.content.findName('VolumeThumb_FocusInAnimation').begin()}));
  75. this.slPlugin.content.findName("VolumeThumb").addEventListener("MouseLeave", Function.createDelegate(this, function(){this.slPlugin.content.findName('VolumeThumb_FocusOutAnimation').begin()}));
  76. this.slPlugin.content.findName("FullScreenButton").addEventListener("MouseEnter", Function.createDelegate(this, function(){this.slPlugin.content.findName('FullScreenButton_FocusInAnimation').begin()}));
  77. this.slPlugin.content.findName("FullScreenButton").addEventListener("MouseLeave", Function.createDelegate(this, function(){this.slPlugin.content.findName('FullScreenButton_FocusOutAnimation').begin()}));
  78.     
  79.     
  80. },
  81.     _onMediaEnded: function(sender, eventArgs) {
  82.     }
  83. }