Only show play button for torrents that are playable
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
module.exports = {
|
||||
isPlayable,
|
||||
isVideo,
|
||||
isAudio
|
||||
isAudio,
|
||||
isPlayableTorrent
|
||||
}
|
||||
|
||||
var path = require('path')
|
||||
@@ -22,3 +23,7 @@ function isAudio (file) {
|
||||
var ext = path.extname(file.name)
|
||||
return ['.mp3', '.aac', '.ogg', '.wav'].indexOf(ext) !== -1
|
||||
}
|
||||
|
||||
function isPlayableTorrent (torrentSummary) {
|
||||
return torrentSummary.files && torrentSummary.files.some(isPlayable)
|
||||
}
|
||||
|
||||
@@ -137,14 +137,22 @@ function TorrentList (state) {
|
||||
downloadTooltip = 'Click to start torrenting.'
|
||||
}
|
||||
|
||||
return hx`
|
||||
<div class='buttons'>
|
||||
// Only show the play button for torrents that contain playable media
|
||||
var playButton
|
||||
if (TorrentPlayer.isPlayableTorrent(torrentSummary)) {
|
||||
playButton = hx`
|
||||
<i.btn.icon.play
|
||||
title=${playTooltip}
|
||||
class=${playClass}
|
||||
onclick=${dispatcher('play', infoHash)}>
|
||||
${playIcon}
|
||||
</i>
|
||||
`
|
||||
}
|
||||
|
||||
return hx`
|
||||
<div class='buttons'>
|
||||
${playButton}
|
||||
<i.btn.icon.download
|
||||
class=${torrentSummary.status}
|
||||
title=${downloadTooltip}
|
||||
|
||||
Reference in New Issue
Block a user