123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- function DynamicPlayer()
- {
-
- this.play = function(object_for_player, player_type, ref_id, element_id, autoplay, finish_callback, play_callback)
- {
- autoplay = typeof autoplay !== 'undefined' ? autoplay : false;
- finish_callback = typeof finish_callback !== 'undefined' ? finish_callback : $.noop;
- play_callback = typeof play_callback !== 'undefined' ? play_callback : $.noop;
-
- if ((player = getPlayerObjectForElementType(object_for_player, player_type, ref_id, element_id, autoplay, finish_callback)))
- {
- player.play(play_callback);
- return player;
- }
-
- return false;
- }
-
- var getPlayerObjectForElementType = function(object_for_player, player_type, ref_id, element_id, autoplay, finish_callback)
- {
- if (player_type == 'youtube.com' || player_type == 'youtu.be')
- {
- return new YoutubePlayer(ref_id, object_for_player, finish_callback);
- }
- if (player_type == 'soundcloud.com')
- {
- return new SoundCloudPlayer(ref_id, object_for_player, finish_callback, autoplay);
- }
- if (player_type == 'jamendo.com')
- {
- return new JamendoPlayer(element_id, object_for_player, finish_callback);
- }
-
- if (!autoplay && element_id)
- {
- return new GenericPlayer(element_id, object_for_player);
- }
-
- return false;
- }
-
- }
-
- function PlayersManager()
- {
- var _players = new Array();
-
- this.add = function(player, key)
- {
- _players[key] = player;
- }
-
- this.get = function(key)
- {
- return _players[key];
- }
-
- this.remove = function(key)
- {
- delete _players[key];
- }
-
- this.getAll = function()
- {
- return _players;
- }
- }
-
- $(document).ready(function() {
- window.dynamic_player = new DynamicPlayer();
- window.players_manager = new PlayersManager();
- });
|