Changeset 2772

Show
Ignore:
Timestamp:
2007-05-22 05:43:29 (2 years ago)
Author:
ctford
Message:

Autodetect whether the VLC api used is the old or new one (does plugin.playlist exist?).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • AnnodexFirefoxExtension/branches/cafe/Core/chrome/afeview/content/MediaEngine.js

    r2770 r2772  
    5454// getVideoHeight 
    5555 
    56 // Implements the VLC javascript API for VLC >= 0.8.5 
    57 function NewVLCMediaEngine (pluginObject) 
     56function mplayerMediaEngine (pluginObject) 
    5857{ 
    5958  this.pluginObject = pluginObject; 
    6059 
     60  this.loadUrl = function (url) 
     61  { 
     62    dump("Opening filename\n"); 
     63    pluginObject.Open(url); 
     64    dump("Playing\n"); 
     65    pluginObject.Play(); 
     66    return true; 
     67  } 
     68 
     69  this.getTimeInSeconds = function () 
     70  { 
     71    return pluginObject.getTime(); 
     72  } 
     73 
     74  this.getStreamLengthInSeconds = function () 
     75  { 
     76    return pluginObject.getDuration(); 
     77  } 
     78 
     79  this.setHRef = function (href) 
     80  { 
     81  } 
     82 
     83  this.pause = function () 
     84  { 
     85    pluginObject.Pause(); 
     86  } 
     87 
     88  this.play = function () 
     89  { 
     90    pluginObject.Play(); 
     91  } 
     92 
     93  this.stop = function () 
     94  { 
     95    pluginObject.Stop(); 
     96  } 
     97 
     98  this.goToBeginning = function () 
     99  { 
     100    pluginObject.Seek(0); 
     101  } 
     102 
     103  this.goToEnd = function () 
     104  { 
     105    pluginObject.Seek( pluginObject.getDuration() ); 
     106  } 
     107 
     108  this.setTimeInSeconds = function (seconds) 
     109  { 
     110    pluginObject.Seek( seconds ); 
     111  } 
     112 
     113  this.getVolume = function () 
     114  { 
     115    return pluginObject.GetVolume(); 
     116  } 
     117 
     118  this.setVolume = function (aVolumeLevelBetween0And100) 
     119  { 
     120    pluginObject.SetVolume(aVolumeLevelBetween0And100); 
     121  } 
     122 
     123  this.getVideoWidth = function () 
     124  { 
     125    return 300; 
     126  } 
     127 
     128  this.getVideoHeight = function () 
     129  { 
     130    return 300; 
     131  } 
     132 
     133  this.internalName = function () 
     134  { 
     135    return "mplayerplug-in"; 
     136  } 
     137 
     138/*  this.videoViewXULElementName = function () 
     139  { 
     140    return "mplayerplug-in"; 
     141  }*/ 
     142} 
     143mplayerMediaEngine.videoViewXULElementName = function () 
     144{ 
     145  return "mplayerview"; 
     146} 
     147 
     148// Implements deprecated javascript API for VLC < 0.8.5 
     149function VLCMediaEngine (pluginObject) 
     150{ 
     151 this.pluginObject = pluginObject; 
     152 
     153 // Old api? < VLC 0.8.5 
     154 if( pluginObject.playlist == null ) 
     155 { 
     156 
     157  this.loadUrl = function (url) 
     158  { 
     159    dump("Clearing playlist\n"); 
     160    pluginObject.clear_playlist(); 
     161    dump("Adding item\n"); 
     162    pluginObject.add_item(url); 
     163    dump("Playing\n"); 
     164    pluginObject.play(); 
     165    return true; 
     166  } 
     167 
     168  this.getTimeInSeconds = function () 
     169  { 
     170    return pluginObject.get_time(); 
     171  } 
     172 
     173  this.getStreamLengthInSeconds = function () 
     174  { 
     175    return pluginObject.get_length(); 
     176  } 
     177 
     178  this.setHRef = function (href) 
     179  { 
     180    // VLC doesn't support clicking on the video view 
     181  } 
     182 
     183  this.pause = function () 
     184  { 
     185    pluginObject.pause(); 
     186  } 
     187 
     188  this.play = function () 
     189  { 
     190    pluginObject.play(); 
     191  } 
     192 
     193  this.stop = function () 
     194  { 
     195    pluginObject.stop(); 
     196  } 
     197 
     198  this.goToBeginning = function () 
     199  { 
     200    pluginObject.seek(0); 
     201  } 
     202 
     203  this.goToEnd = function () 
     204  { 
     205    pluginObject.seek(pluginObject.get_length(), 0); 
     206  } 
     207 
     208  this.setTimeInSeconds = function (seconds) 
     209  { 
     210    pluginObject.seek(seconds, 0); 
     211  } 
     212 
     213  this.getVolume = function () 
     214  { 
     215    return pluginObject.get_volume(); 
     216  } 
     217 
     218  this.setVolume = function (aVolumeLevelBetween0And100) 
     219  { 
     220    pluginObject.set_volume(aVolumeLevelBetween0And100); 
     221  } 
     222 
     223  this.getVideoWidth = function () 
     224  { 
     225    return pluginObject.get_video_width(); 
     226  } 
     227 
     228  this.getVideoHeight = function () 
     229  { 
     230    return pluginObject.get_video_height(); 
     231  } 
     232 
     233 } else // New api. >= VLC 0.8.5 
     234 { 
    61235  this.loadUrl = function (url) 
    62236  { 
     
    141315    return pluginObject.video.height; 
    142316  } 
    143  
    144   this.internalName = function () 
    145  
    146     return "VLC"; 
    147  
    148 } 
    149 NewVLCMediaEngine.videoViewXULElementName = function () 
     317 } 
     318 this.internalName = function () 
     319 
     320   return "VLC"; 
     321 
     322} 
     323VLCMediaEngine.videoViewXULElementName = function () 
    150324{ 
    151325  if (navigator.platform.match(/^Linux/)) 
     
    158332  } 
    159333} 
    160  
    161 function mplayerMediaEngine (pluginObject) 
    162 { 
    163   this.pluginObject = pluginObject; 
    164  
    165   this.loadUrl = function (url) 
    166   { 
    167     dump("Opening filename\n"); 
    168     pluginObject.Open(url); 
    169     dump("Playing\n"); 
    170     pluginObject.Play(); 
    171     return true; 
    172   } 
    173  
    174   this.getTimeInSeconds = function () 
    175   { 
    176     return pluginObject.getTime(); 
    177   } 
    178  
    179   this.getStreamLengthInSeconds = function () 
    180   { 
    181     return pluginObject.getDuration(); 
    182   } 
    183  
    184   this.setHRef = function (href) 
    185   { 
    186   } 
    187  
    188   this.pause = function () 
    189   { 
    190     pluginObject.Pause(); 
    191   } 
    192  
    193   this.play = function () 
    194   { 
    195     pluginObject.Play(); 
    196   } 
    197  
    198   this.stop = function () 
    199   { 
    200     pluginObject.Stop(); 
    201   } 
    202  
    203   this.goToBeginning = function () 
    204   { 
    205     pluginObject.Seek(0); 
    206   } 
    207  
    208   this.goToEnd = function () 
    209   { 
    210     pluginObject.Seek( pluginObject.getDuration() ); 
    211   } 
    212  
    213   this.setTimeInSeconds = function (seconds) 
    214   { 
    215     pluginObject.Seek( seconds ); 
    216   } 
    217  
    218   this.getVolume = function () 
    219   { 
    220     return pluginObject.GetVolume(); 
    221   } 
    222  
    223   this.setVolume = function (aVolumeLevelBetween0And100) 
    224   { 
    225     pluginObject.SetVolume(aVolumeLevelBetween0And100); 
    226   } 
    227  
    228   this.getVideoWidth = function () 
    229   { 
    230     return 300; 
    231   } 
    232  
    233   this.getVideoHeight = function () 
    234   { 
    235     return 300; 
    236   } 
    237  
    238   this.internalName = function () 
    239   { 
    240     return "mplayerplug-in"; 
    241   } 
    242  
    243 /*  this.videoViewXULElementName = function () 
    244   { 
    245     return "mplayerplug-in"; 
    246   }*/ 
    247 } 
    248 mplayerMediaEngine.videoViewXULElementName = function () 
    249 { 
    250   return "mplayerview"; 
    251 } 
    252  
    253 // Implements deprecated javascript API for VLC < 0.8.5 
    254 function VLCMediaEngine (pluginObject) 
    255 { 
    256   this.pluginObject = pluginObject; 
    257  
    258   this.loadUrl = function (url) 
    259   { 
    260     dump("Clearing playlist\n"); 
    261     pluginObject.clear_playlist(); 
    262     dump("Adding item\n"); 
    263     pluginObject.add_item(url); 
    264     dump("Playing\n"); 
    265     pluginObject.play(); 
    266     return true; 
    267   } 
    268  
    269   this.getTimeInSeconds = function () 
    270   { 
    271     return pluginObject.get_time(); 
    272   } 
    273  
    274   this.getStreamLengthInSeconds = function () 
    275   { 
    276     return pluginObject.get_length(); 
    277   } 
    278  
    279   this.setHRef = function (href) 
    280   { 
    281     // VLC doesn't support clicking on the video view 
    282   } 
    283  
    284   this.pause = function () 
    285   { 
    286     pluginObject.pause(); 
    287   } 
    288  
    289   this.play = function () 
    290   { 
    291     pluginObject.play(); 
    292   } 
    293  
    294   this.stop = function () 
    295   { 
    296     pluginObject.stop(); 
    297   } 
    298  
    299   this.goToBeginning = function () 
    300   { 
    301     pluginObject.seek(0); 
    302   } 
    303  
    304   this.goToEnd = function () 
    305   { 
    306     pluginObject.seek(pluginObject.get_length(), 0); 
    307   } 
    308  
    309   this.setTimeInSeconds = function (seconds) 
    310   { 
    311     pluginObject.seek(seconds, 0); 
    312   } 
    313  
    314   this.getVolume = function () 
    315   { 
    316     return pluginObject.get_volume(); 
    317   } 
    318  
    319   this.setVolume = function (aVolumeLevelBetween0And100) 
    320   { 
    321     pluginObject.set_volume(aVolumeLevelBetween0And100); 
    322   } 
    323  
    324   this.getVideoWidth = function () 
    325   { 
    326     return pluginObject.get_video_width(); 
    327   } 
    328  
    329   this.getVideoHeight = function () 
    330   { 
    331     return pluginObject.get_video_height(); 
    332   } 
    333  
    334   this.internalName = function () 
    335   { 
    336     return "VLC"; 
    337   } 
    338 } 
    339 VLCMediaEngine.videoViewXULElementName = function () 
    340 { 
    341   if (navigator.platform.match(/^Linux/)) 
    342   { 
    343     return "vlcview-linux"; 
    344   } 
    345   else 
    346   { 
    347     return "vlcview"; 
    348   } 
    349 } 
    350  
    351334 
    352335function DirectShowMediaEngine (pluginObject)