Only show play button for torrents that are playable

This commit is contained in:
DC
2016-04-06 02:24:50 -07:00
parent 08a806a643
commit aac862cddf
2 changed files with 16 additions and 3 deletions

View File

@@ -1,7 +1,8 @@
module.exports = { module.exports = {
isPlayable, isPlayable,
isVideo, isVideo,
isAudio isAudio,
isPlayableTorrent
} }
var path = require('path') var path = require('path')
@@ -22,3 +23,7 @@ function isAudio (file) {
var ext = path.extname(file.name) var ext = path.extname(file.name)
return ['.mp3', '.aac', '.ogg', '.wav'].indexOf(ext) !== -1 return ['.mp3', '.aac', '.ogg', '.wav'].indexOf(ext) !== -1
} }
function isPlayableTorrent (torrentSummary) {
return torrentSummary.files && torrentSummary.files.some(isPlayable)
}

View File

@@ -137,14 +137,22 @@ function TorrentList (state) {
downloadTooltip = 'Click to start torrenting.' downloadTooltip = 'Click to start torrenting.'
} }
return hx` // Only show the play button for torrents that contain playable media
<div class='buttons'> var playButton
if (TorrentPlayer.isPlayableTorrent(torrentSummary)) {
playButton = hx`
<i.btn.icon.play <i.btn.icon.play
title=${playTooltip} title=${playTooltip}
class=${playClass} class=${playClass}
onclick=${dispatcher('play', infoHash)}> onclick=${dispatcher('play', infoHash)}>
${playIcon} ${playIcon}
</i> </i>
`
}
return hx`
<div class='buttons'>
${playButton}
<i.btn.icon.download <i.btn.icon.download
class=${torrentSummary.status} class=${torrentSummary.status}
title=${downloadTooltip} title=${downloadTooltip}