@@ -712,16 +712,21 @@ function startServerFromReadyTorrent (torrent, index, cb) {
|
|||||||
// update state
|
// update state
|
||||||
state.playing.infoHash = torrent.infoHash
|
state.playing.infoHash = torrent.infoHash
|
||||||
state.playing.fileIndex = index
|
state.playing.fileIndex = index
|
||||||
state.playing.type = TorrentPlayer.isVideo(file) ? 'video' : 'audio'
|
state.playing.type = TorrentPlayer.isVideo(file) ? 'video'
|
||||||
state.playing.audioInfo = null
|
: TorrentPlayer.isAudio(file) ? 'audio'
|
||||||
|
: 'other'
|
||||||
|
|
||||||
// if it's audio, parse out the metadata (artist, title, etc)
|
// if it's audio, parse out the metadata (artist, title, etc)
|
||||||
musicmetadata(file.createReadStream(), function (err, info) {
|
var torrentSummary = getTorrentSummary(torrent.infoHash)
|
||||||
if (err) return
|
var fileSummary = torrentSummary.files[index]
|
||||||
console.log('got audio metadata for %s: %v', file.name, info)
|
if (state.playing.type === 'audio' && !fileSummary.audioInfo) {
|
||||||
state.playing.audioInfo = info
|
musicmetadata(file.createReadStream(), function (err, info) {
|
||||||
update()
|
if (err) return
|
||||||
})
|
console.log('got audio metadata for %s: %o', file.name, info)
|
||||||
|
fileSummary.audioInfo = info
|
||||||
|
update()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// either way, start a streaming torrent-to-http server
|
// either way, start a streaming torrent-to-http server
|
||||||
var server = torrent.createServer()
|
var server = torrent.createServer()
|
||||||
@@ -777,6 +782,7 @@ function openPlayer (infoHash, index, cb) {
|
|||||||
|
|
||||||
var timeout = setTimeout(function () {
|
var timeout = setTimeout(function () {
|
||||||
torrentSummary.playStatus = 'timeout' /* no seeders available? */
|
torrentSummary.playStatus = 'timeout' /* no seeders available? */
|
||||||
|
state.navigation.clearPending()
|
||||||
playInterfaceSound('ERROR')
|
playInterfaceSound('ERROR')
|
||||||
update()
|
update()
|
||||||
}, 10000) /* give it a few seconds */
|
}, 10000) /* give it a few seconds */
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ LocationHistory.prototype._go = function (page) {
|
|||||||
this._pending = page
|
this._pending = page
|
||||||
page.onbeforeload((err) => {
|
page.onbeforeload((err) => {
|
||||||
if (err) return
|
if (err) return
|
||||||
|
if (this._pending !== page) return /* navigation was cancelled */
|
||||||
this._pending = null
|
this._pending = null
|
||||||
this._history.push(page)
|
this._history.push(page)
|
||||||
})
|
})
|
||||||
@@ -67,3 +68,7 @@ LocationHistory.prototype.hasForward = function () {
|
|||||||
LocationHistory.prototype.pending = function () {
|
LocationHistory.prototype.pending = function () {
|
||||||
return this._pending
|
return this._pending
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LocationHistory.prototype.clearPending = function () {
|
||||||
|
this._pending = null
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ module.exports = {
|
|||||||
infoHash: null, /* the info hash of the torrent we're playing */
|
infoHash: null, /* the info hash of the torrent we're playing */
|
||||||
fileIndex: null, /* the zero-based index within the torrent */
|
fileIndex: null, /* the zero-based index within the torrent */
|
||||||
location: 'local', /* 'local', 'chromecast', 'airplay' */
|
location: 'local', /* 'local', 'chromecast', 'airplay' */
|
||||||
type: null, /* 'audio' or 'video' */
|
type: null, /* 'audio' or 'video', could be 'other' if ever support eg streaming to VLC */
|
||||||
currentTime: 0, /* seconds */
|
currentTime: 0, /* seconds */
|
||||||
duration: 1, /* seconds */
|
duration: 1, /* seconds */
|
||||||
isPaused: true,
|
isPaused: true,
|
||||||
@@ -32,7 +32,6 @@ module.exports = {
|
|||||||
lastTimeUpdate: 0, /* Unix time in ms */
|
lastTimeUpdate: 0, /* Unix time in ms */
|
||||||
mouseStationarySince: 0 /* Unix time in ms */
|
mouseStationarySince: 0 /* Unix time in ms */
|
||||||
},
|
},
|
||||||
audioInfo: null, /* set whenever an audio file is playing */
|
|
||||||
pendingTorrents: {}, /* infohash to WebTorrent handle */
|
pendingTorrents: {}, /* infohash to WebTorrent handle */
|
||||||
devices: { /* playback devices like Chromecast and AppleTV */
|
devices: { /* playback devices like Chromecast and AppleTV */
|
||||||
airplay: null, /* airplay client. finds and manages AppleTVs */
|
airplay: null, /* airplay client. finds and manages AppleTVs */
|
||||||
|
|||||||
@@ -122,14 +122,15 @@ function renderOverlay (state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderAudioMetadata (state) {
|
function renderAudioMetadata (state) {
|
||||||
if (!state.playing.audioInfo) return
|
var torrentSummary = getPlayingTorrentSummary(state)
|
||||||
var info = state.playing.audioInfo
|
var fileSummary = torrentSummary.files[state.playing.fileIndex]
|
||||||
|
if (!fileSummary.audioInfo) return
|
||||||
|
var info = fileSummary.audioInfo
|
||||||
|
|
||||||
// Get audio track info
|
// Get audio track info
|
||||||
var title = info.title
|
var title = info.title
|
||||||
if (!title) {
|
if (!title) {
|
||||||
var torrentSummary = getPlayingTorrentSummary(state)
|
title = fileSummary.name
|
||||||
title = torrentSummary.files[state.playing.fileIndex].name
|
|
||||||
}
|
}
|
||||||
var artist = info.artist && info.artist[0]
|
var artist = info.artist && info.artist[0]
|
||||||
var album = info.album
|
var album = info.album
|
||||||
|
|||||||
Reference in New Issue
Block a user