Skip to content

Commit

Permalink
Look for subtitles next to local file
Browse files Browse the repository at this point in the history
  • Loading branch information
freeall committed Apr 12, 2015
1 parent 83b1f01 commit 8524de5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ mouseidle($('#idle')[0], 3000, 'hide-cursor')
list.on('select', function () {
$('#controls-name')[0].innerText = list.selected.name
media.play('http://127.0.0.1:' + server.address().port + '/' + list.selected.id)
if (list.selected.subtitle) fs.createReadStream(list.selected.subtitle).pipe(vtt()).pipe(concat(onsubs))
updatePlaylist()
})

Expand Down
20 changes: 18 additions & 2 deletions playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,24 @@ module.exports = function () {
}

file.id = that.entries.push(file) - 1
that.emit('update')
cb()

var ondone = function () {
that.emit('update')
cb()
}
var subtitleSrt = link.substr(0, link.lastIndexOf('.')) + '.srt'
var subtitleVtt = link.substr(0, link.lastIndexOf('.')) + '.srt'
fs.exists(subtitleSrt, function (exists) {
if (exists) {
file.subtitle = subtitleSrt
ondone()
return
}
fs.exists(subtitleVtt, function (exists) {
if (exists) file.subtitle = subtitleVtt
ondone()
})
})
})
}

Expand Down

0 comments on commit 8524de5

Please sign in to comment.