f792d24_play2_13.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. function DynamicPlayer()
  2. {
  3. this.play = function(object_for_player, player_type, ref_id, element_id, autoplay, finish_callback)
  4. {
  5. autoplay = typeof autoplay !== 'undefined' ? autoplay : false;
  6. finish_callback = typeof finish_callback !== 'undefined' ? finish_callback : $.noop;
  7. if ((player = getPlayerObjectForElementType(object_for_player, player_type, ref_id, element_id, autoplay, finish_callback)))
  8. {
  9. player.play();
  10. return player;
  11. }
  12. return false;
  13. }
  14. var getPlayerObjectForElementType = function(object_for_player, player_type, ref_id, element_id, autoplay, finish_callback)
  15. {
  16. if (player_type == 'youtube.com' || player_type == 'youtu.be')
  17. {
  18. return new YoutubePlayer(ref_id, object_for_player, finish_callback);
  19. }
  20. if (player_type == 'soundcloud.com')
  21. {
  22. return new SoundCloudPlayer(ref_id, object_for_player, finish_callback, autoplay);
  23. }
  24. if (player_type == 'jamendo.com')
  25. {
  26. return new JamendoPlayer(element_id, object_for_player, finish_callback);
  27. }
  28. if (!autoplay && element_id)
  29. {
  30. return new GenericPlayer(element_id, object_for_player);
  31. }
  32. return false;
  33. }
  34. }
  35. function PlayersManager()
  36. {
  37. var _players = new Array();
  38. this.add = function(player, key)
  39. {
  40. _players[key] = player;
  41. }
  42. this.get = function(key)
  43. {
  44. return _players[key];
  45. }
  46. this.remove = function(key)
  47. {
  48. delete _players[key];
  49. }
  50. this.getAll = function()
  51. {
  52. return _players;
  53. }
  54. }
  55. $(document).ready(function() {
  56. window.dynamic_player = new DynamicPlayer();
  57. window.players_manager = new PlayersManager();
  58. });