1ae784e_play2_13.js 1.7KB

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