| | |
| | | */ |
| | | setPlayerFullscreen: null |
| | | }, |
| | | _callCallback: function(callback, arg_types) { |
| | | var cbInfo = HUMBLE_API.callbacks[callback]; |
| | | if (cbInfo == null) return false; |
| | | var cb = cbInfo[0], |
| | | data = cbInfo[1], |
| | | js = cbInfo[2], |
| | | args = Array.prototype.slice.call(arguments, 2); |
| | | |
| | | args.push(data); |
| | | |
| | | if (js) { |
| | | cb.apply(null, args); |
| | | } else { |
| | | Runtime.dynCall(arg_types, cb, args); |
| | | } |
| | | return true; |
| | | }, |
| | | /** |
| | | * Attempts to call into the app to inform it that the volume should be adjusted |
| | | * @param volume the float volume (between 0.0 and 1.0) |
| | | * @return bool.. true if the callback was successful.. false if no callback registered |
| | | */ |
| | | setPlayerVolume: function(volume) { |
| | | if (HUMBLE_API.callbacks.setPlayerVolume == null) return false; |
| | | var cb = HUMBLE_API.callbacks.setPlayerVolume[0], |
| | | data = HUMBLE_API.callbacks.setPlayerVolume[1]; |
| | | if (volume > 1.0) volume = 1.0; |
| | | if (volume < 0.0) volume = 0.0; |
| | | Runtime.dynCall('vdi', cb, [volume, data]); |
| | | return true; |
| | | return this._callCallback('setPlayerVolume', 'vdi', volume); |
| | | }, |
| | | /** |
| | | * Attempts to call into the app to inform it that it should change to or from fullscreen mode |
| | |
| | | * @return bool.. true if the callback was successful.. false if no callback registered |
| | | */ |
| | | setPlayerFullscreen: function(fullscreen) { |
| | | if (HUMBLE_API.callbacks.setPlayerFullscreen == null) return false; |
| | | var cb = HUMBLE_API.callbacks.setPlayerFullscreen[0], |
| | | data = HUMBLE_API.callbacks.setPlayerFullscreen[1]; |
| | | Runtime.dynCall('vii', cb, [fullscreen ? 1 : 0, data]); |
| | | return true; |
| | | return this._callCallback('setPlayerFullscreen', 'vii', fullscreen ? 1 : 0); |
| | | }, |
| | | /** |
| | | * setCallback |
| | | */ |
| | | setCallback: function(type, cb, data) { |
| | | if (cb == null) { |
| | | HUMBLE_API.callbacks[type] = null; |
| | | } else { |
| | | HUMBLE_API.callbacks[type] = [cb, data, true]; |
| | | } |
| | | }, |
| | | /** |
| | | * allows configuring the HUMBLE_API simply call this method in a preRun to initialize.. |
| | |
| | | if (cb == 0) { |
| | | HUMBLE_API.callbacks[key] = null; |
| | | } else { |
| | | HUMBLE_API.callbacks[key] = [cb, data]; |
| | | HUMBLE_API.callbacks[key] = [cb, data, false]; |
| | | } |
| | | return 1; |
| | | }, |