1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

bump dev version

This commit is contained in:
Luke Pulverenti 2015-05-28 01:51:48 -04:00
parent 6daced8387
commit 48a576778f
28 changed files with 443 additions and 326 deletions

View file

@ -12,23 +12,97 @@
//AndroidFullScreen.isSupported();
//// Is immersive mode supported?
//AndroidFullScreen.isImmersiveModeSupported(successFunction, errorFunction);
//AndroidFullScreen.isImmersiveModeSupported(onSuccess, onError);
//// The width of the screen in immersive mode
//AndroidFullScreen.immersiveWidth(trace, errorFunction);
//AndroidFullScreen.immersiveWidth(trace, onError);
//// The height of the screen in immersive mode
//AndroidFullScreen.immersiveHeight(trace, errorFunction);
//AndroidFullScreen.immersiveHeight(trace, onError);
//// Hide system UI until user interacts
//AndroidFullScreen.leanMode(successFunction, errorFunction);
//AndroidFullScreen.leanMode(onSuccess, onError);
//// Show system UI
//AndroidFullScreen.showSystemUI(successFunction, errorFunction);
//AndroidFullScreen.showSystemUI(onSuccess, onError);
//// Extend your app underneath the system UI (Android 4.4+ only)
//AndroidFullScreen.showUnderSystemUI(successFunction, errorFunction);
//AndroidFullScreen.showUnderSystemUI(onSuccess, onError);
//// Hide system UI and keep it hidden (Android 4.4+ only)
//AndroidFullScreen.immersiveMode(successFunction, errorFunction);
//AndroidFullScreen.immersiveMode(onSuccess, onError);
var currentPlayer;
function onPlaybackStart(e, state) {
var player = this;
if (player.isLocalPlayer && state.NowPlayingItem && state.NowPlayingItem.MediaType == 'Video') {
AndroidFullScreen.immersiveMode(onSuccess, onError);
}
}
function onPlaybackStopped(e, state) {
var player = this;
if (player.isLocalPlayer && state.NowPlayingItem && state.NowPlayingItem.MediaType == 'Video') {
AndroidFullScreen.showSystemUI(onSuccess, onError);
}
}
function bindToPlayer(player) {
releaseCurrentPlayer();
currentPlayer = player;
if (!player.isLocalPlayer) {
return;
}
$(player).on('playbackstart.fullscreen', onPlaybackStart)
.on('playbackstop.fullscreen', onPlaybackStopped);
}
function releaseCurrentPlayer() {
if (currentPlayer) {
$(currentPlayer).off('.fullscreen');
}
}
function updateFromSetting(leaveFullScreen) {
if (AppSettings.enableFullScreen()) {
AndroidFullScreen.immersiveMode(onSuccess, onError);
}
else if (leaveFullScreen) {
AndroidFullScreen.showSystemUI(onSuccess, onError);
}
}
Dashboard.ready(function () {
console.log('binding fullscreen to MediaController');
$(MediaController).on('playerchange', function () {
bindToPlayer(MediaController.getCurrentPlayer());
});
bindToPlayer(MediaController.getCurrentPlayer());
updateFromSetting(false);
$(AppSettings).on('settingupdated', function (e, key) {
if (key == 'enableFullScreen') {
updateFromSetting(true);
}
});
});
})();

View file

@ -6,6 +6,7 @@
var currentPairedDeviceId;
var currentDeviceFriendlyName;
var currentWebAppSession;
var currentDevice;
function chromecastPlayer() {
@ -312,6 +313,10 @@
};
self.seek = function (position) {
position = parseInt(position);
position = position / 10000000;
sendMessageToDevice({
options: {
position: position
@ -441,18 +446,38 @@
}
}
function onSessionConnected(device, session) {
function handleMessage(message) {
// message could be either a string or an object
if (typeof message === 'string') {
onMessage(JSON.parse(message));
} else {
onMessage(message);
}
}
function handleSessionDisconnect() {
console.log("session disconnected");
cleanupSession();
MediaController.removeActivePlayer(PlayerName);
}
function setupWebAppSession(device, session) {
// hold on to a reference
currentWebAppSession = session.acquire();
session.connect().success(function () {
currentWebAppSession.on('message', handleMessage);
currentWebAppSession.on('disconnect', handleSessionDisconnect);
currentWebAppSession.connect().success(function () {
console.log('session.connect succeeded');
MediaController.setActivePlayer(PlayerName, convertDeviceToTarget(device));
currentDeviceFriendlyName = device.getFriendlyName();
currentPairedDeviceId = device.getId();
currentDevice = device;
$(castPlayer).trigger('connect');
@ -460,34 +485,32 @@
options: {},
command: 'Identify'
});
});
session.on('message', function (message) {
// message could be either a string or an object
if (typeof message === 'string') {
onMessage(JSON.parse(message));
} else {
onMessage(message);
}
});
session.on('disconnect', function () {
console.log("session disconnected");
if (currentPairedDeviceId == device.getId()) {
onDisconnected();
MediaController.removeActivePlayer(PlayerName);
}
});
}).error(handleSessionError);
}
function onDisconnected() {
function handleSessionError() {
cleanupSession();
}
function cleanupSession() {
var session = currentWebAppSession;
if (session) {
// Clean up listeners
session.off("message");
session.off("disconnect");
// Release session to free up memory
session.disconnect();
session.release();
}
currentWebAppSession = null;
currentPairedDeviceId = null;
currentDeviceFriendlyName = null;
currentDevice = null;
}
function launchWebApp(device) {
@ -497,7 +520,7 @@
device.getWebAppLauncher().joinWebApp(ApplicationID).success(function (session) {
console.log('joinWebApp success. calling onSessionConnected');
onSessionConnected(device, session);
setupWebAppSession(device, session);
}).error(function (err) {
@ -506,7 +529,7 @@
device.getWebAppLauncher().launchWebApp(ApplicationID).success(function (session) {
console.log('launchWebApp success. calling onSessionConnected');
onSessionConnected(device, session);
setupWebAppSession(device, session);
}).error(function (err1) {
@ -533,46 +556,18 @@
}, 0);
}
var boundHandlers = [];
self.tryPair = function (target) {
var deferred = $.Deferred();
var manager = ConnectSDK.discoveryManager;
var device = manager.getDeviceList().filter(function (d) {
var device = ConnectSDK.discoveryManager.getDeviceList().filter(function (d) {
return d.getId() == target.id;
})[0];
if (device) {
var deviceId = device.getId();
currentPairingDeviceId = deviceId;
console.log('Will attempt to connect to Chromecast');
if (device.isReady()) {
console.log('Device is already ready, calling onDeviceReady');
onDeviceReady(device);
} else {
console.log('Binding device ready handler');
if (boundHandlers.indexOf(deviceId) == -1) {
boundHandlers.push(deviceId);
device.on("ready", function () {
console.log('device.ready fired');
onDeviceReady(device);
});
}
console.log('Calling device.connect');
device.connect();
}
//deferred.resolve();
self.tryPairWithDevice(device, deferred);
} else {
deferred.reject();
@ -581,6 +576,34 @@
return deferred.promise();
};
self.tryPairWithDevice = function (device, deferred) {
var deviceId = device.getId();
currentPairingDeviceId = deviceId;
console.log('Will attempt to connect to Chromecast');
if (device.isReady()) {
console.log('Device is already ready, calling onDeviceReady');
onDeviceReady(device);
} else {
console.log('Binding device ready handler');
device.on("ready", function () {
console.log('device.ready fired');
onDeviceReady(device);
});
device.on("disconnect", function () {
device.off("ready");
});
console.log('Calling device.connect');
device.connect();
}
};
$(MediaController).on('playerchange', function (e, newPlayer, newTarget) {
if (currentPairedDeviceId) {
@ -588,7 +611,6 @@
if (currentWebAppSession) {
console.log('Disconnecting from chromecast');
currentWebAppSession.disconnect();
onDisconnected();
}
}
}

View file

@ -2,6 +2,8 @@
var updatedProducts = [];
var unlockAlias = "premium features";
function updateProductInfo(p) {
updatedProducts = updatedProducts.filter(function (r) {
@ -11,6 +13,26 @@
updatedProducts.push(p);
}
function getProduct(alias) {
var products = updatedProducts.filter(function (r) {
return r.alias == alias;
});
return products.length ? products[0] : null;
}
function hasPurchased(alias) {
var product = getProduct(alias);
return product != null && product.owned;
}
function isPurchaseAvailable(alias) {
var product = getProduct(alias);
return product != null && product.canPurchase;
}
function isAndroid() {
var platform = (device.platform || '').toLowerCase();
@ -29,7 +51,7 @@
validateFeature({
id: 'appunlock',
alias: "premium features"
alias: unlockAlias
}, deferred);
}
@ -45,7 +67,7 @@
validateFeature({
id: 'premiumunlock',
alias: "premium features"
alias: unlockAlias
}, deferred);
}
@ -61,7 +83,7 @@
validateFeature({
id: 'premiumunlock',
alias: "premium features"
alias: unlockAlias
}, deferred);
}
@ -78,24 +100,20 @@
function validateFeature(info, deferred) {
var products = updatedProducts.filter(function (r) {
return r.alias == info.alias;
});
var product = products.length ? products[0] : null;
if (product && product.owned) {
if (hasPurchased(info.alias)) {
deferred.resolve();
return;
}
var productInfo = {
enableSupporterUnlock: isAndroid(),
enableAppUnlock: product != null && product.canPurchase
enableAppUnlock: isPurchaseAvailable(info.alias)
};
var prefix = isAndroid() ? 'android' : 'ios';
// Get supporter status
getRegistrationInfo('appunlock', productInfo.enableSupporterUnlock).done(function (registrationInfo) {
getRegistrationInfo(prefix + 'appunlock', productInfo.enableSupporterUnlock).done(function (registrationInfo) {
if (registrationInfo.IsRegistered) {
deferred.resolve();
@ -267,38 +285,32 @@
function initializeStore() {
if (isAndroid()) {
return;
}
// Let's set a pretty high verbosity level, so that we see a lot of stuff
// in the console (reassuring us that something is happening).
store.verbosity = store.INFO;
store.validator = validateProduct;
if (isAndroid) {
store.register({
id: "premiumunlock",
alias: "premium features",
type: store.NON_CONSUMABLE
});
} else {
// iOS
store.register({
id: "appunlock",
alias: "premium features",
type: store.NON_CONSUMABLE
});
}
// iOS
store.register({
id: "appunlock",
alias: unlockAlias,
type: store.NON_CONSUMABLE
});
// When purchase of the full version is approved,
// show some logs and finish the transaction.
store.when("premium feautres").approved(function (order) {
store.when(unlockAlias).approved(function (order) {
log('You just unlocked the FULL VERSION!');
order.finish();
});
// The play button can only be accessed when the user
// owns the full version.
store.when("premium feautres").updated(function (product) {
store.when(unlockAlias).updated(function (product) {
updateProductInfo(product);
});
@ -309,11 +321,11 @@
store.ready(function () {
console.log("Store ready");
// After we've done our setup, we tell the store to do
// it's first refresh. Nothing will happen if we do not call store.refresh()
store.refresh();
});
// After we've done our setup, we tell the store to do
// it's first refresh. Nothing will happen if we do not call store.refresh()
store.refresh();
}
// We must wait for the "deviceready" event to fire

View file

@ -48,25 +48,23 @@
return deferred.promise();
}
var isTimedOut = false;
var timeout;
var socketId;
function onTimerExpired() {
deferred.resolveWith(null, [servers]);
if (socketId) {
chrome.sockets.udp.onReceive.removeListener(onReceive);
closeSocket(socketId);
}
}
function startTimer() {
console.log('starting udp receive timer with timeout ms: ' + timeoutMs);
timeout = setTimeout(function () {
isTimedOut = true;
deferred.resolveWith(null, [servers]);
if (socketId) {
chrome.sockets.udp.onReceive.removeListener(onReceive);
closeSocket(socketId);
}
}, timeoutMs);
timeout = setTimeout(onTimerExpired, timeoutMs);
}
function onReceive(info) {
@ -98,48 +96,42 @@
var port = 7359;
console.log('chrome.sockets.udp.create');
startTimer();
chrome.sockets.udp.create(function (createInfo) {
if (!createInfo) {
console.log('create fail');
deferred.resolveWith(null, [servers]);
return;
}
if (!createInfo.socketId) {
console.log('create fail');
deferred.resolveWith(null, [servers]);
return;
}
socketId = createInfo.socketId;
console.log('chrome.sockets.udp.bind');
chrome.sockets.udp.bind(createInfo.socketId, '0.0.0.0', 0, function (bindResult) {
if (getResultCode(bindResult) != 0) {
console.log('bind fail: ' + bindResult);
deferred.resolveWith(null, [servers]);
closeSocket(createInfo.socketId);
return;
}
var data = stringToArrayBuffer('who is EmbyServer?');
console.log('chrome.sockets.udp.send');
chrome.sockets.udp.send(createInfo.socketId, data, '255.255.255.255', port, function (sendResult) {
if (getResultCode(sendResult) != 0) {
console.log('send fail: ' + sendResult);
deferred.resolveWith(null, [servers]);
closeSocket(createInfo.socketId);
} else {
console.log('sendTo: success ' + port);
startTimer();
chrome.sockets.udp.onReceive.addListener(onReceive);
console.log('sendTo: success ' + port);
}
});
});
@ -163,10 +155,10 @@
}).fail(function () {
deferred.reject();
deferred.resolveWith(null, [[]]);
});
} catch (err) {
deferred.reject();
deferred.resolveWith(null, [[]]);
}
});