Fix chromecast button
Next step: Chromecast and Airplay play/pause, scrub, and state management When casting, the correct cast button should be lit up and the video should be replaced with a title image and text
This commit is contained in:
@@ -190,10 +190,10 @@ function dispatch (action, ...args) {
|
|||||||
toggleSelectTorrent(args[0] /* infoHash */)
|
toggleSelectTorrent(args[0] /* infoHash */)
|
||||||
}
|
}
|
||||||
if (action === 'openChromecast') {
|
if (action === 'openChromecast') {
|
||||||
openChromecast(args[0] /* infoHash */)
|
openChromecast()
|
||||||
}
|
}
|
||||||
if (action === 'openAirplay') {
|
if (action === 'openAirplay') {
|
||||||
openAirplay(args[0] /* infoHash */)
|
openAirplay()
|
||||||
}
|
}
|
||||||
if (action === 'setDimensions') {
|
if (action === 'setDimensions') {
|
||||||
setDimensions(args[0] /* dimensions */)
|
setDimensions(args[0] /* dimensions */)
|
||||||
@@ -283,6 +283,9 @@ function loadState (callback) {
|
|||||||
|
|
||||||
// populate defaults if they're not there
|
// populate defaults if they're not there
|
||||||
state.saved = Object.assign({}, state.defaultSavedState, data)
|
state.saved = Object.assign({}, state.defaultSavedState, data)
|
||||||
|
state.saved.torrents.forEach(function (torrentSummary) {
|
||||||
|
if (torrentSummary.displayName) torrentSummary.name = torrentSummary.displayName
|
||||||
|
})
|
||||||
|
|
||||||
if (callback) callback()
|
if (callback) callback()
|
||||||
})
|
})
|
||||||
@@ -424,7 +427,7 @@ function addTorrentEvents (torrent) {
|
|||||||
var torrentSummary = getTorrentSummary(torrent.infoHash)
|
var torrentSummary = getTorrentSummary(torrent.infoHash)
|
||||||
torrentSummary.status = 'downloading'
|
torrentSummary.status = 'downloading'
|
||||||
torrentSummary.ready = true
|
torrentSummary.ready = true
|
||||||
torrentSummary.name = torrent.name
|
torrentSummary.name = torrentSummary.displayName || torrent.name
|
||||||
torrentSummary.infoHash = torrent.infoHash
|
torrentSummary.infoHash = torrent.infoHash
|
||||||
|
|
||||||
if (!torrentSummary.posterURL) {
|
if (!torrentSummary.posterURL) {
|
||||||
@@ -595,8 +598,8 @@ function toggleSelectTorrent (infoHash) {
|
|||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
function openChromecast (infoHash) {
|
function openChromecast () {
|
||||||
var torrentSummary = getTorrentSummary(infoHash)
|
var torrentSummary = getTorrentSummary(state.playing.infoHash)
|
||||||
state.devices.chromecast.play(state.server.networkURL, {
|
state.devices.chromecast.play(state.server.networkURL, {
|
||||||
title: config.APP_NAME + ' — ' + torrentSummary.name
|
title: config.APP_NAME + ' — ' + torrentSummary.name
|
||||||
})
|
})
|
||||||
@@ -607,7 +610,7 @@ function openChromecast (infoHash) {
|
|||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
function openAirplay (infoHash) {
|
function openAirplay () {
|
||||||
state.devices.airplay.play(state.server.networkURL, 0, function () {
|
state.devices.airplay.play(state.server.networkURL, 0, function () {
|
||||||
// TODO: handle airplay errors
|
// TODO: handle airplay errors
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ function Player (state, dispatch) {
|
|||||||
function renderPlayerControls (state, dispatch) {
|
function renderPlayerControls (state, dispatch) {
|
||||||
var positionPercent = 100 * state.video.currentTime / state.video.duration
|
var positionPercent = 100 * state.video.currentTime / state.video.duration
|
||||||
var playbackCursorStyle = { left: 'calc(' + positionPercent + '% - 8px)' }
|
var playbackCursorStyle = { left: 'calc(' + positionPercent + '% - 8px)' }
|
||||||
var torrent = state.client.get(state.playing.infoHash)
|
|
||||||
|
|
||||||
var elements = [
|
var elements = [
|
||||||
hx`
|
hx`
|
||||||
@@ -88,7 +87,7 @@ function renderPlayerControls (state, dispatch) {
|
|||||||
if (state.devices.chromecast) {
|
if (state.devices.chromecast) {
|
||||||
elements.push(hx`
|
elements.push(hx`
|
||||||
<i.icon.chromecast
|
<i.icon.chromecast
|
||||||
onclick=${() => dispatch('openChromecast', torrent)}>
|
onclick=${() => dispatch('openChromecast')}>
|
||||||
cast
|
cast
|
||||||
</i>
|
</i>
|
||||||
`)
|
`)
|
||||||
@@ -96,7 +95,7 @@ function renderPlayerControls (state, dispatch) {
|
|||||||
if (state.devices.airplay) {
|
if (state.devices.airplay) {
|
||||||
elements.push(hx`
|
elements.push(hx`
|
||||||
<i.icon.airplay
|
<i.icon.airplay
|
||||||
onclick=${() => dispatch('openAirplay', torrent)}>
|
onclick=${() => dispatch('openAirplay')}>
|
||||||
airplay
|
airplay
|
||||||
</i>
|
</i>
|
||||||
`)
|
`)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ function TorrentList (state, dispatch) {
|
|||||||
|
|
||||||
// Show name, download status, % complete
|
// Show name, download status, % complete
|
||||||
function renderTorrentMetadata (torrent, torrentSummary) {
|
function renderTorrentMetadata (torrent, torrentSummary) {
|
||||||
var name = torrentSummary.displayName || torrentSummary.name || 'Loading torrent...'
|
var name = torrentSummary.name || 'Loading torrent...'
|
||||||
var elements = [hx`
|
var elements = [hx`
|
||||||
<div class='name ellipsis'>${name}</div>
|
<div class='name ellipsis'>${name}</div>
|
||||||
`]
|
`]
|
||||||
|
|||||||
Reference in New Issue
Block a user