update script loading
This commit is contained in:
parent
463ad6cfb1
commit
bbdbdf346e
92 changed files with 1062 additions and 518 deletions
14
dashboard-ui/thirdparty/apiclient/apiclient.js
vendored
14
dashboard-ui/thirdparty/apiclient/apiclient.js
vendored
|
@ -345,7 +345,7 @@
|
|||
return url;
|
||||
};
|
||||
|
||||
self.enableAutomaticNetworking = function (server, connectionMode) {
|
||||
self.enableAutomaticNetworking = function (server, connectionMode, serverUrl) {
|
||||
|
||||
logger.log('Begin enableAutomaticNetworking');
|
||||
|
||||
|
@ -353,12 +353,8 @@
|
|||
self.connectionMode = connectionMode;
|
||||
self.enableAutomaticNetwork = true;
|
||||
|
||||
var url = connectionMode == MediaBrowser.ConnectionMode.Local ?
|
||||
self.serverInfo().LocalAddress :
|
||||
self.serverInfo().RemoteAddress;
|
||||
|
||||
logger.log('Setting server address to ' + url);
|
||||
self.serverAddress(url);
|
||||
logger.log('Setting server address to ' + serverUrl);
|
||||
self.serverAddress(serverUrl);
|
||||
};
|
||||
|
||||
self.isWebSocketSupported = function () {
|
||||
|
@ -570,12 +566,12 @@
|
|||
return self.ajax({
|
||||
type: "POST",
|
||||
url: url
|
||||
}).done(done);
|
||||
}).always(done);
|
||||
}
|
||||
|
||||
var deferred = DeferredBuilder.Deferred();
|
||||
deferred.resolveWith(null, []);
|
||||
return deferred.promise().done(done);
|
||||
return deferred.promise().always(done);
|
||||
};
|
||||
|
||||
function getRemoteImagePrefix(options) {
|
||||
|
|
|
@ -479,6 +479,7 @@
|
|||
for (var j = 0, numServers = servers.length; j < numServers; j++) {
|
||||
|
||||
var server = servers[j];
|
||||
|
||||
server.UserId = null;
|
||||
server.AccessToken = null;
|
||||
server.ExchangeToken = null;
|
||||
|
@ -902,7 +903,7 @@
|
|||
MediaBrowser.ConnectionState.ServerSignIn;
|
||||
|
||||
result.Servers.push(server);
|
||||
result.ApiClient.enableAutomaticNetworking(server, connectionMode);
|
||||
result.ApiClient.enableAutomaticNetworking(server, connectionMode, self.getServerAddress(server, connectionMode));
|
||||
|
||||
if (result.State == MediaBrowser.ConnectionState.SignedIn) {
|
||||
afterConnected(result.ApiClient, options);
|
||||
|
@ -947,6 +948,11 @@
|
|||
|
||||
address = normalizeAddress(address);
|
||||
|
||||
function onFail() {
|
||||
logger.log('connectToAddress ' + address + ' failed');
|
||||
resolveWithFailure(deferred);
|
||||
}
|
||||
|
||||
tryConnect(address, 15000).done(function (publicInfo) {
|
||||
|
||||
logger.log('connectToAddress ' + address + ' succeeded');
|
||||
|
@ -961,13 +967,9 @@
|
|||
|
||||
deferred.resolveWith(null, [result]);
|
||||
|
||||
});
|
||||
}).fail(onFail);
|
||||
|
||||
}).fail(function () {
|
||||
|
||||
logger.log('connectToAddress ' + address + ' failed');
|
||||
resolveWithFailure(deferred);
|
||||
});
|
||||
}).fail(onFail);
|
||||
|
||||
return deferred.promise();
|
||||
};
|
||||
|
|
|
@ -290,11 +290,12 @@
|
|||
|
||||
function isChromecast(name) {
|
||||
|
||||
name = (name || '').toLowerCase();
|
||||
var validTokens = ['nexusplayer', 'chromecast', 'eurekadongle'];
|
||||
|
||||
return validTokens.filter(function (t) {
|
||||
|
||||
return name.toLowerCase().replace(' ', '').indexOf(t) != -1;
|
||||
return name.replace(' ', '').indexOf(t) != -1;
|
||||
|
||||
}).length > 0;
|
||||
}
|
||||
|
|
12
dashboard-ui/thirdparty/cordova/connectsdk.js
vendored
12
dashboard-ui/thirdparty/cordova/connectsdk.js
vendored
|
@ -15,8 +15,8 @@
|
|||
|
||||
var manager = ConnectSDK.discoveryManager;
|
||||
|
||||
manager.setPairingLevel(ConnectSDK.PairingLevel.OFF);
|
||||
manager.setAirPlayServiceMode(ConnectSDK.AirPlayServiceMode.Media);
|
||||
//manager.setPairingLevel(ConnectSDK.PairingLevel.OFF);
|
||||
//manager.setAirPlayServiceMode(ConnectSDK.AirPlayServiceMode.Media);
|
||||
|
||||
// Show devices that support playing videos and pausing
|
||||
//manager.setCapabilityFilters([
|
||||
|
@ -28,14 +28,10 @@
|
|||
|
||||
manager.startDiscovery();
|
||||
|
||||
requirejs(['thirdparty/cordova/chromecast']);
|
||||
requirejs(['thirdparty/cordova/chromecast', 'thirdparty/cordova/generaldevice']);
|
||||
}
|
||||
|
||||
document.addEventListener("deviceready", function () {
|
||||
|
||||
initSdk();
|
||||
|
||||
}, false);
|
||||
Dashboard.ready(initSdk);
|
||||
|
||||
|
||||
})();
|
566
dashboard-ui/thirdparty/cordova/generaldevice.js
vendored
Normal file
566
dashboard-ui/thirdparty/cordova/generaldevice.js
vendored
Normal file
|
@ -0,0 +1,566 @@
|
|||
(function () {
|
||||
|
||||
var currentPairingDeviceId;
|
||||
var currentDevice;
|
||||
|
||||
var PlayerName = "ConnectSDK";
|
||||
|
||||
function connectPlayer() {
|
||||
|
||||
var self = this;
|
||||
|
||||
// MediaController needs this
|
||||
self.name = PlayerName;
|
||||
|
||||
self.getItemsForPlayback = function (query) {
|
||||
|
||||
var userId = Dashboard.getCurrentUserId();
|
||||
|
||||
query.Limit = query.Limit || 100;
|
||||
query.ExcludeLocationTypes = "Virtual";
|
||||
|
||||
return ApiClient.getItems(userId, query);
|
||||
};
|
||||
|
||||
var castPlayer = {};
|
||||
|
||||
$(castPlayer).on("playbackstart", function (e, data) {
|
||||
|
||||
console.log('cc: playbackstart');
|
||||
|
||||
var state = self.getPlayerStateInternal(data);
|
||||
$(self).trigger("playbackstart", [state]);
|
||||
});
|
||||
|
||||
$(castPlayer).on("playbackstop", function (e, data) {
|
||||
|
||||
console.log('cc: playbackstop');
|
||||
var state = self.getPlayerStateInternal(data);
|
||||
|
||||
$(self).trigger("playbackstop", [state]);
|
||||
|
||||
// Reset this so the next query doesn't make it appear like content is playing.
|
||||
self.lastPlayerData = {};
|
||||
});
|
||||
|
||||
$(castPlayer).on("playbackprogress", function (e, data) {
|
||||
|
||||
console.log('cc: positionchange');
|
||||
var state = self.getPlayerStateInternal(data);
|
||||
|
||||
$(self).trigger("positionchange", [state]);
|
||||
});
|
||||
|
||||
self.play = function (options) {
|
||||
|
||||
Dashboard.getCurrentUser().done(function (user) {
|
||||
|
||||
if (options.items) {
|
||||
|
||||
self.playWithCommand(options, 'PlayNow');
|
||||
|
||||
} else {
|
||||
|
||||
self.getItemsForPlayback({
|
||||
|
||||
Ids: options.ids.join(',')
|
||||
|
||||
}).done(function (result) {
|
||||
|
||||
options.items = result.Items;
|
||||
self.playWithCommand(options, 'PlayNow');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
self.playWithCommand = function (options, command) {
|
||||
|
||||
if (!options.items) {
|
||||
ApiClient.getItem(Dashboard.getCurrentUserId(), options.ids[0]).done(function (item) {
|
||||
|
||||
options.items = [item];
|
||||
self.playWithCommand(options, command);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
playInternal(options.items);
|
||||
};
|
||||
|
||||
function playInternal(items, serverAddress) {
|
||||
|
||||
playItemInternal(items[0], null, serverAddress);
|
||||
|
||||
}
|
||||
|
||||
function playItemInternal(items, startPosition) {
|
||||
|
||||
if (item == null) {
|
||||
throw new Error("item cannot be null");
|
||||
}
|
||||
|
||||
if (item.MediaType !== 'Audio' && item.MediaType !== 'Video') {
|
||||
throw new Error("Unrecognized media type");
|
||||
}
|
||||
|
||||
if (item.IsPlaceHolder) {
|
||||
MediaController.showPlaybackInfoErrorMessage('PlaceHolder');
|
||||
return;
|
||||
}
|
||||
|
||||
var deviceProfile = self.getDeviceProfile();
|
||||
|
||||
if (item.MediaType === "Video") {
|
||||
|
||||
Dashboard.showModalLoadingMsg();
|
||||
}
|
||||
|
||||
//getPlaybackInfo(item.Id, deviceProfile, startPosition).done(function (playbackInfoResult) {
|
||||
|
||||
// if (validatePlaybackInfoResult(playbackInfoResult)) {
|
||||
|
||||
// var mediaSource = getOptimalMediaSource(item.MediaType, playbackInfoResult.MediaSources);
|
||||
|
||||
// if (mediaSource) {
|
||||
|
||||
// if (mediaSource.RequiresOpening) {
|
||||
|
||||
// getLiveStream(item.Id, playbackInfoResult.PlaySessionId, deviceProfile, startPosition, mediaSource, null, null).done(function (openLiveStreamResult) {
|
||||
|
||||
// openLiveStreamResult.MediaSource.enableDirectPlay = supportsDirectPlay(openLiveStreamResult.MediaSource);
|
||||
|
||||
// playInternalPostMediaSourceSelection(item, openLiveStreamResult.MediaSource, startPosition, callback);
|
||||
// });
|
||||
|
||||
// } else {
|
||||
// playInternalPostMediaSourceSelection(item, mediaSource, startPosition, callback);
|
||||
// }
|
||||
// } else {
|
||||
// Dashboard.hideModalLoadingMsg();
|
||||
// MediaController.showPlaybackInfoErrorMessage('NoCompatibleStream');
|
||||
// }
|
||||
// }
|
||||
|
||||
//});
|
||||
}
|
||||
|
||||
self.unpause = function () {
|
||||
currentDevice.getMediaControl().play();
|
||||
};
|
||||
|
||||
self.pause = function () {
|
||||
currentDevice.getMediaControl().pause();
|
||||
};
|
||||
|
||||
self.shuffle = function (id) {
|
||||
|
||||
var userId = Dashboard.getCurrentUserId();
|
||||
|
||||
ApiClient.getItem(userId, id).done(function (item) {
|
||||
|
||||
self.playWithCommand({
|
||||
|
||||
items: [item]
|
||||
|
||||
}, 'Shuffle');
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
self.instantMix = function (id) {
|
||||
|
||||
var userId = Dashboard.getCurrentUserId();
|
||||
|
||||
ApiClient.getItem(userId, id).done(function (item) {
|
||||
|
||||
self.playWithCommand({
|
||||
|
||||
items: [item]
|
||||
|
||||
}, 'InstantMix');
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
self.canQueueMediaType = function (mediaType) {
|
||||
return false;
|
||||
};
|
||||
|
||||
self.queue = function (options) {
|
||||
};
|
||||
|
||||
self.queueNext = function (options) {
|
||||
};
|
||||
|
||||
self.stop = function () {
|
||||
currentDevice.getMediaControl().stop();
|
||||
};
|
||||
|
||||
self.displayContent = function (options) {
|
||||
|
||||
};
|
||||
|
||||
self.mute = function () {
|
||||
currentDevice.getVolumeControl().setMute(true);
|
||||
};
|
||||
|
||||
self.unMute = function () {
|
||||
currentDevice.getVolumeControl().setMute(false);
|
||||
};
|
||||
|
||||
self.toggleMute = function () {
|
||||
|
||||
var volumeControl = currentDevice.getVolumeControl();
|
||||
|
||||
volumeControl.setMute(!volumeControl.getMute());
|
||||
};
|
||||
|
||||
self.getDeviceProfile = function () {
|
||||
|
||||
var qualityOption = self.getVideoQualityOptions().filter(function (q) {
|
||||
return q.selected;
|
||||
})[0];
|
||||
|
||||
var bitrateSetting = AppSettings.maxStreamingBitrate();
|
||||
|
||||
var profile = {};
|
||||
|
||||
profile.MaxStreamingBitrate = bitrateSetting;
|
||||
profile.MaxStaticBitrate = 40000000;
|
||||
profile.MusicStreamingTranscodingBitrate = Math.min(bitrateSetting, 192000);
|
||||
|
||||
profile.DirectPlayProfiles = [];
|
||||
profile.DirectPlayProfiles.push({
|
||||
Container: 'mp4,m4v',
|
||||
Type: 'Video',
|
||||
VideoCodec: 'h264',
|
||||
AudioCodec: 'aac,mp3,ac3'
|
||||
});
|
||||
profile.DirectPlayProfiles.push({
|
||||
Container: 'mov',
|
||||
Type: 'Video'
|
||||
});
|
||||
|
||||
profile.DirectPlayProfiles.push({
|
||||
Container: 'mp3',
|
||||
Type: 'Audio'
|
||||
});
|
||||
|
||||
profile.DirectPlayProfiles.push({
|
||||
Container: 'aac',
|
||||
Type: 'Audio'
|
||||
});
|
||||
|
||||
profile.TranscodingProfiles = [];
|
||||
profile.TranscodingProfiles.push({
|
||||
Container: 'mp3',
|
||||
Type: 'Audio',
|
||||
AudioCodec: 'mp3',
|
||||
Context: 'Streaming',
|
||||
Protocol: 'http'
|
||||
});
|
||||
|
||||
if (self.canPlayHls()) {
|
||||
profile.TranscodingProfiles.push({
|
||||
Container: 'ts',
|
||||
Type: 'Video',
|
||||
AudioCodec: 'aac',
|
||||
VideoCodec: 'h264',
|
||||
Context: 'Streaming',
|
||||
Protocol: 'hls'
|
||||
});
|
||||
}
|
||||
|
||||
profile.TranscodingProfiles.push({
|
||||
Container: 'mp4',
|
||||
Type: 'Video',
|
||||
AudioCodec: 'aac',
|
||||
VideoCodec: 'h264',
|
||||
Context: 'Streaming',
|
||||
Protocol: 'http'
|
||||
});
|
||||
|
||||
profile.ContainerProfiles = [];
|
||||
|
||||
profile.CodecProfiles = [];
|
||||
profile.CodecProfiles.push({
|
||||
Type: 'Audio',
|
||||
Conditions: [{
|
||||
Condition: 'LessThanEqual',
|
||||
Property: 'AudioChannels',
|
||||
Value: '2'
|
||||
}]
|
||||
});
|
||||
|
||||
profile.CodecProfiles.push({
|
||||
Type: 'VideoAudio',
|
||||
Codec: 'aac,mp3',
|
||||
Conditions: [
|
||||
{
|
||||
Condition: 'LessThanEqual',
|
||||
Property: 'AudioChannels',
|
||||
Value: '6'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
profile.CodecProfiles.push({
|
||||
Type: 'Video',
|
||||
Codec: 'h264',
|
||||
Conditions: [
|
||||
{
|
||||
Condition: 'NotEquals',
|
||||
Property: 'IsAnamorphic',
|
||||
Value: 'true',
|
||||
IsRequired: false
|
||||
},
|
||||
{
|
||||
Condition: 'EqualsAny',
|
||||
Property: 'VideoProfile',
|
||||
Value: 'high|main|baseline|constrained baseline'
|
||||
},
|
||||
{
|
||||
Condition: 'LessThanEqual',
|
||||
Property: 'VideoLevel',
|
||||
Value: '41'
|
||||
},
|
||||
{
|
||||
Condition: 'LessThanEqual',
|
||||
Property: 'Width',
|
||||
Value: qualityOption.maxWidth
|
||||
}]
|
||||
});
|
||||
|
||||
// Subtitle profiles
|
||||
profile.SubtitleProfiles = [];
|
||||
profile.ResponseProfiles = [];
|
||||
|
||||
profile.ResponseProfiles.push({
|
||||
Type: 'Video',
|
||||
Container: 'm4v',
|
||||
MimeType: 'video/mp4'
|
||||
});
|
||||
|
||||
//profile.ResponseProfiles.push({
|
||||
// Type: 'Video',
|
||||
// Container: 'mkv',
|
||||
// MimeType: 'video/webm'
|
||||
//});
|
||||
|
||||
return profile;
|
||||
};
|
||||
|
||||
|
||||
function getBaseTargetInfo() {
|
||||
var target = {};
|
||||
|
||||
target.playableMediaTypes = ["Audio", "Video"];
|
||||
target.isLocalPlayer = false;
|
||||
target.supportedCommands = [
|
||||
"VolumeUp",
|
||||
"VolumeDown",
|
||||
"Mute",
|
||||
"Unmute",
|
||||
"ToggleMute",
|
||||
"SetVolume"
|
||||
];
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
function convertDeviceToTarget(device) {
|
||||
|
||||
var target = getBaseTargetInfo();
|
||||
|
||||
target.appName = target.name = target.deviceName = device.getFriendlyName();
|
||||
target.playerName = PlayerName;
|
||||
target.id = device.getId();
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
function isValid(device) {
|
||||
|
||||
var validTokens = ['AirPlay', 'Airplay', 'airplay'];
|
||||
|
||||
return validTokens.filter(function (t) {
|
||||
|
||||
return device.hasService(t);
|
||||
|
||||
}).length > 0;
|
||||
}
|
||||
|
||||
self.getTargets = function () {
|
||||
|
||||
var manager = ConnectSDK.discoveryManager;
|
||||
|
||||
return manager.getDeviceList().filter(function (d) {
|
||||
|
||||
return isValid(d);
|
||||
|
||||
}).map(convertDeviceToTarget);
|
||||
};
|
||||
|
||||
self.seek = function (position) {
|
||||
};
|
||||
|
||||
self.setAudioStreamIndex = function (index) {
|
||||
};
|
||||
|
||||
self.setSubtitleStreamIndex = function (index) {
|
||||
};
|
||||
|
||||
self.nextTrack = function () {
|
||||
};
|
||||
|
||||
self.previousTrack = function () {
|
||||
};
|
||||
|
||||
self.beginPlayerUpdates = function () {
|
||||
// Setup polling here
|
||||
};
|
||||
|
||||
self.endPlayerUpdates = function () {
|
||||
// Stop polling here
|
||||
};
|
||||
|
||||
function getCurrentVolume() {
|
||||
var state = self.lastPlayerData || {};
|
||||
state = state.PlayState || {};
|
||||
|
||||
return state.VolumeLevel == null ? 100 : state.VolumeLevel;
|
||||
}
|
||||
|
||||
self.volumeDown = function () {
|
||||
|
||||
currentDevice.getVolumeControl().volumeDown();
|
||||
};
|
||||
|
||||
self.volumeUp = function () {
|
||||
|
||||
currentDevice.getVolumeControl().volumeUp();
|
||||
};
|
||||
|
||||
self.setVolume = function (vol) {
|
||||
|
||||
vol = Math.min(vol, 100);
|
||||
vol = Math.max(vol, 0);
|
||||
|
||||
currentDevice.getVolumeControl().setVolume(vol / 100);
|
||||
};
|
||||
|
||||
self.getPlayerState = function () {
|
||||
|
||||
var deferred = $.Deferred();
|
||||
|
||||
var result = self.getPlayerStateInternal();
|
||||
|
||||
deferred.resolveWith(null, [result]);
|
||||
|
||||
return deferred.promise();
|
||||
};
|
||||
|
||||
self.lastPlayerData = {};
|
||||
|
||||
self.getPlayerStateInternal = function (data) {
|
||||
|
||||
data = data || self.lastPlayerData;
|
||||
self.lastPlayerData = data;
|
||||
|
||||
console.log(JSON.stringify(data));
|
||||
return data;
|
||||
};
|
||||
|
||||
function onDisconnected(device) {
|
||||
|
||||
if (currentDevice && device.getId() == currentDevice.getId()) {
|
||||
MediaController.removeActiveTarget(device.getId());
|
||||
}
|
||||
}
|
||||
|
||||
function onDeviceReady(device) {
|
||||
|
||||
if (currentPairingDeviceId != device.getId()) {
|
||||
console.log('device ready fired for a different device. ignoring.');
|
||||
return;
|
||||
}
|
||||
|
||||
currentDevice = device;
|
||||
MediaController.setActivePlayer(PlayerName, convertDeviceToTarget(device));
|
||||
}
|
||||
|
||||
var boundHandlers = [];
|
||||
|
||||
self.tryPair = function (target) {
|
||||
|
||||
var deferred = $.Deferred();
|
||||
|
||||
var manager = ConnectSDK.discoveryManager;
|
||||
|
||||
var device = manager.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 device');
|
||||
|
||||
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);
|
||||
});
|
||||
device.on("disconnect", function () {
|
||||
console.log('device.disconnect fired');
|
||||
onDisconnected(device);
|
||||
});
|
||||
}
|
||||
|
||||
console.log('Calling device.connect');
|
||||
device.connect();
|
||||
}
|
||||
//deferred.resolve();
|
||||
|
||||
} else {
|
||||
deferred.reject();
|
||||
}
|
||||
|
||||
return deferred.promise();
|
||||
};
|
||||
|
||||
$(MediaController).on('playerchange', function (e, newPlayer, newTarget) {
|
||||
|
||||
if (currentDevice && newTarget.id != currentDevice.getId()) {
|
||||
MediaController.removeActiveTarget(currentDevice.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initSdk() {
|
||||
|
||||
MediaController.registerPlayer(new connectPlayer());
|
||||
}
|
||||
|
||||
initSdk();
|
||||
|
||||
})();
|
|
@ -157,22 +157,17 @@
|
|||
.on('positionchange.cordovaremote', onStateChanged);
|
||||
}
|
||||
|
||||
console.log('binding remotecontrols to MediaController');
|
||||
|
||||
document.addEventListener("deviceready", function () {
|
||||
Dashboard.ready(function () {
|
||||
|
||||
console.log('binding remotecontrols to MediaController');
|
||||
|
||||
$(function () {
|
||||
|
||||
$(MediaController).on('playerchange', function () {
|
||||
|
||||
bindToPlayer(MediaController.getCurrentPlayer());
|
||||
});
|
||||
$(MediaController).on('playerchange', function () {
|
||||
|
||||
bindToPlayer(MediaController.getCurrentPlayer());
|
||||
});
|
||||
|
||||
}, false);
|
||||
bindToPlayer(MediaController.getCurrentPlayer());
|
||||
|
||||
});
|
||||
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue