Add tooltips
This commit is contained in:
@@ -456,7 +456,8 @@ input {
|
|||||||
background-color: #F44336;
|
background-color: #F44336;
|
||||||
}
|
}
|
||||||
|
|
||||||
.torrent.timeout .play {
|
.torrent.timeout .play,
|
||||||
|
.torrent.unplayable .play {
|
||||||
padding-top: 8px;
|
padding-top: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ var patch = require('virtual-dom/patch')
|
|||||||
|
|
||||||
var App = require('./views/app')
|
var App = require('./views/app')
|
||||||
var Cast = require('./lib/cast')
|
var Cast = require('./lib/cast')
|
||||||
|
var errors = require('./lib/errors')
|
||||||
var config = require('../config')
|
var config = require('../config')
|
||||||
var TorrentPlayer = require('./lib/torrent-player')
|
var TorrentPlayer = require('./lib/torrent-player')
|
||||||
var torrentPoster = require('./lib/torrent-poster')
|
var torrentPoster = require('./lib/torrent-poster')
|
||||||
@@ -601,7 +602,7 @@ function startServerFromReadyTorrent (torrent, index, cb) {
|
|||||||
if (!index) {
|
if (!index) {
|
||||||
// filter out file formats that the <video> tag definitely can't play
|
// filter out file formats that the <video> tag definitely can't play
|
||||||
var files = torrent.files.filter(TorrentPlayer.isPlayable)
|
var files = torrent.files.filter(TorrentPlayer.isPlayable)
|
||||||
if (files.length === 0) return cb(new Error('Can\'t play any files in torrent'))
|
if (files.length === 0) return cb(new errors.UnplayableError())
|
||||||
// use largest file
|
// use largest file
|
||||||
var largestFile = files.reduce(function (a, b) {
|
var largestFile = files.reduce(function (a, b) {
|
||||||
return a.length > b.length ? a : b
|
return a.length > b.length ? a : b
|
||||||
@@ -648,13 +649,18 @@ function openPlayer (torrentSummary, index, cb) {
|
|||||||
}, 10000) /* give it a few seconds */
|
}, 10000) /* give it a few seconds */
|
||||||
|
|
||||||
startServer(torrentSummary, index, function (err) {
|
startServer(torrentSummary, index, function (err) {
|
||||||
if (err) return onError(err)
|
clearTimeout(timeout)
|
||||||
|
if (err) {
|
||||||
|
torrentSummary.playStatus = 'unplayable'
|
||||||
|
playInterfaceSound(config.SOUND_ERROR)
|
||||||
|
update()
|
||||||
|
return onError(err)
|
||||||
|
}
|
||||||
|
|
||||||
// if we timed out (user clicked play a long time ago), don't autoplay
|
// if we timed out (user clicked play a long time ago), don't autoplay
|
||||||
clearTimeout(timeout)
|
|
||||||
var timedOut = torrentSummary.playStatus === 'timeout'
|
var timedOut = torrentSummary.playStatus === 'timeout'
|
||||||
delete torrentSummary.playStatus
|
delete torrentSummary.playStatus
|
||||||
if (timedOut) return
|
if (timedOut) return update()
|
||||||
|
|
||||||
// otherwise, play the video
|
// otherwise, play the video
|
||||||
state.window.title = torrentSummary.name
|
state.window.title = torrentSummary.name
|
||||||
|
|||||||
8
renderer/lib/errors.js
Normal file
8
renderer/lib/errors.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
module.exports = {
|
||||||
|
UnplayableError
|
||||||
|
}
|
||||||
|
|
||||||
|
function UnplayableError () {
|
||||||
|
this.message = 'Can\'t play any files in torrent'
|
||||||
|
}
|
||||||
|
UnplayableError.prototype = Error
|
||||||
@@ -11,13 +11,13 @@ function Header (state, dispatch) {
|
|||||||
<div class='nav left'>
|
<div class='nav left'>
|
||||||
<i.icon.back
|
<i.icon.back
|
||||||
class=${state.location.hasBack() ? '' : 'disabled'}
|
class=${state.location.hasBack() ? '' : 'disabled'}
|
||||||
title='back'
|
title='Back'
|
||||||
onclick=${() => dispatch('back')}>
|
onclick=${() => dispatch('back')}>
|
||||||
chevron_left
|
chevron_left
|
||||||
</i>
|
</i>
|
||||||
<i.icon.forward
|
<i.icon.forward
|
||||||
class=${state.location.hasForward() ? '' : 'disabled'}
|
class=${state.location.hasForward() ? '' : 'disabled'}
|
||||||
title='forward'
|
title='Forward'
|
||||||
onclick=${() => dispatch('forward')}>
|
onclick=${() => dispatch('forward')}>
|
||||||
chevron_right
|
chevron_right
|
||||||
</i>
|
</i>
|
||||||
@@ -39,7 +39,7 @@ function Header (state, dispatch) {
|
|||||||
return hx`
|
return hx`
|
||||||
<i
|
<i
|
||||||
class='icon add'
|
class='icon add'
|
||||||
title='add torrent'
|
title='Add torrent'
|
||||||
onclick=${() => dispatch('showOpenTorrentFile')}>
|
onclick=${() => dispatch('showOpenTorrentFile')}>
|
||||||
add
|
add
|
||||||
</i>
|
</i>
|
||||||
|
|||||||
@@ -103,19 +103,47 @@ function TorrentList (state, dispatch) {
|
|||||||
// Download button toggles between torrenting (DL/seed) and paused
|
// Download button toggles between torrenting (DL/seed) and paused
|
||||||
// Play button starts streaming the torrent immediately, unpausing if needed
|
// Play button starts streaming the torrent immediately, unpausing if needed
|
||||||
function renderTorrentButtons (torrentSummary) {
|
function renderTorrentButtons (torrentSummary) {
|
||||||
|
var playIcon, playTooltip
|
||||||
|
if (torrentSummary.playStatus === 'unplayable') {
|
||||||
|
playIcon = 'warning'
|
||||||
|
playTooltip = 'Sorry, WebTorrent can\'t play any of the files in this torrent. ' +
|
||||||
|
'View details and click on individual files to open them in another program.'
|
||||||
|
} else if (torrentSummary.playStatus === 'timeout') {
|
||||||
|
playIcon = 'warning'
|
||||||
|
playTooltip = 'Playback timed out. No seeds? No internet? Click to try again.'
|
||||||
|
} else {
|
||||||
|
playIcon = 'play_arrow'
|
||||||
|
playTooltip = 'Start streaming'
|
||||||
|
}
|
||||||
|
|
||||||
|
var downloadIcon, downloadTooltip
|
||||||
|
if (torrentSummary.status === 'seeding') {
|
||||||
|
downloadIcon = 'file_upload'
|
||||||
|
downloadTooltip = 'Seeding. Click to stop.'
|
||||||
|
} else if (torrentSummary.status === 'downloading') {
|
||||||
|
downloadIcon = 'file_download'
|
||||||
|
downloadTooltip = 'Torrenting. Click to stop.'
|
||||||
|
} else {
|
||||||
|
downloadIcon = 'file_download'
|
||||||
|
downloadTooltip = 'Click to start torrenting.'
|
||||||
|
}
|
||||||
|
|
||||||
return hx`
|
return hx`
|
||||||
<div class='buttons'>
|
<div class='buttons'>
|
||||||
<i.btn.icon.play
|
<i.btn.icon.play
|
||||||
|
title='${playTooltip}'
|
||||||
onclick=${(e) => handleButton('play', e)}>
|
onclick=${(e) => handleButton('play', e)}>
|
||||||
${torrentSummary.playStatus === 'timeout' ? 'warning' : 'play_arrow'}
|
${playIcon}
|
||||||
</i>
|
</i>
|
||||||
<i.btn.icon.download
|
<i.btn.icon.download
|
||||||
class='${torrentSummary.status}'
|
class='${torrentSummary.status}'
|
||||||
|
title='${downloadTooltip}'
|
||||||
onclick=${(e) => handleButton('toggleTorrent', e)}>
|
onclick=${(e) => handleButton('toggleTorrent', e)}>
|
||||||
${torrentSummary.status === 'seeding' ? 'file_upload' : 'file_download'}
|
${downloadIcon}
|
||||||
</i>
|
</i>
|
||||||
<i
|
<i
|
||||||
class='icon delete'
|
class='icon delete'
|
||||||
|
title='Remove torrent'
|
||||||
onclick=${(e) => handleButton('deleteTorrent', e)}>
|
onclick=${(e) => handleButton('deleteTorrent', e)}>
|
||||||
close
|
close
|
||||||
</i>
|
</i>
|
||||||
|
|||||||
Reference in New Issue
Block a user