|
| 1 | +//CARDS |
| 2 | +function sepiaFW_build_ui_cards_embed(){ |
| 3 | + var Embed = {}; |
| 4 | + |
| 5 | + //TODO: add MediaPlayer |
| 6 | + /* |
| 7 | + - Controls: start, pause/stop, resume, next, previous |
| 8 | + - State functions: getState, isOnHold |
| 9 | + - Broadcast state change (start, pause, hold, resume, ?) |
| 10 | + - Make sure only one is active |
| 11 | + - Implement async. callback with msgId and timeout |
| 12 | + */ |
| 13 | + |
| 14 | + var activeMediaPlayers = {}; |
| 15 | + |
| 16 | + function getNewMediaPlayerId(){ |
| 17 | + mediaPlayerLastId++; |
| 18 | + var overflow = false; |
| 19 | + if (mediaPlayerLastId >= 20){ |
| 20 | + mediaPlayerLastId = 1; |
| 21 | + overflow = true; |
| 22 | + } |
| 23 | + var newId = ("sepia-embedded-player-" + mediaPlayerLastId); |
| 24 | + if (overflow){ |
| 25 | + //TODO: remove old players |
| 26 | + //activeMediaPlayers ... |
| 27 | + } |
| 28 | + return newId; |
| 29 | + } |
| 30 | + var mediaPlayerLastId = 0; |
| 31 | + |
| 32 | + Embed.MediaPlayer = function(options){ |
| 33 | + if (!options) options = {}; |
| 34 | + var thisPlayer = this; |
| 35 | + |
| 36 | + //ID |
| 37 | + var playerId = getNewMediaPlayerId(); |
| 38 | + thisPlayer.getId = function(){ |
| 39 | + return playerId; |
| 40 | + } |
| 41 | + |
| 42 | + //States |
| 43 | + |
| 44 | + |
| 45 | + //Controls - TODO: implement |
| 46 | + thisPlayer.start = function(doneCallback, errorCallback){ |
| 47 | + |
| 48 | + } |
| 49 | + thisPlayer.pause = function(doneCallback, errorCallback){ |
| 50 | + |
| 51 | + } |
| 52 | + thisPlayer.fadeOut = function(doneCallback, errorCallback){ |
| 53 | + |
| 54 | + } |
| 55 | + thisPlayer.resume = function(doneCallback, errorCallback){ |
| 56 | + |
| 57 | + } |
| 58 | + thisPlayer.fadeIn = function(doneCallback, errorCallback){ |
| 59 | + |
| 60 | + } |
| 61 | + thisPlayer.next = function(doneCallback, errorCallback){ |
| 62 | + |
| 63 | + } |
| 64 | + thisPlayer.previous = function(doneCallback, errorCallback){ |
| 65 | + |
| 66 | + } |
| 67 | + //stop, release resources and remove handle |
| 68 | + thisPlayer.release = function(doneCallback, errorCallback){ |
| 69 | + |
| 70 | + } |
| 71 | + |
| 72 | + //store in list |
| 73 | + activeMediaPlayers[playerId] = thisPlayer; |
| 74 | + } |
| 75 | + |
| 76 | + return Embed; |
| 77 | +} |
0 commit comments