Skip to content

Commit

Permalink
Try some things for subs. Not working on LG WebOS though
Browse files Browse the repository at this point in the history
- partial #236
  • Loading branch information
vankasteelj committed Nov 27, 2024
1 parent 4075ec7 commit 686b3b8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
30 changes: 28 additions & 2 deletions app/js/lib/cast.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,31 @@ const Cast = {
title: title,
dlnaFeatures: 'DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01100000000000000000000000000000',
seek: '0',
autoSubtitles: true
autoSubtitles: false
}
if (subtitle) media.subtitle = [subtitle]

if (subtitle) {
const port = 8000
const subtitlesUrl = 'http://' + DB.sync.get('localip') + ':' + port + '/dlnacaptions.srt'

//build srt server
Cast.subtitleServer = http.createServer((req, res) => {
res.writeHead(200, {
'Content-type': 'text/srt',
'Access-Control-Allow-Origin': '*',
'transferMode.dlna.org': 'Streaming',
'contentFeatures.dlna.org': 'DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000',
'CaptionInfo.sec': subtitlesUrl
})
fs.createReadStream(subtitle).pipe(res)
})

//serve srt
Cast.subtitleServer.listen(port)
media.subtitle = [subtitlesUrl]
}

console.debug('Casting %s to %s (sub: %s)', media.title, player.name, (media.subtitle || 'none'))
player.play(url, media, (err, status) => {
if (err) {
Cast.activePlayer = undefined
Expand Down Expand Up @@ -81,5 +103,9 @@ const Cast = {
Cast.activePlayer = undefined
Details.closeKeepWatchingPopup()
}
if (Cast.subtitleServer) {
Cast.subtitleServer.close()
Cast.subtitleServer = null
}
}
}
12 changes: 10 additions & 2 deletions app/js/main/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,16 @@ const Details = {

const title = $('#details-metadata .titles').text().replace(/\W+/g, ' ')
const url = Streamer.streaminfo.url.replace('127.0.0.1', DB.sync.get('localip'))
const subtitle = undefined // todo
Cast.cast(player.name, title, url, subtitle)
let subtitle = undefined

Player.mpv.getProperty('current-tracks/sub').then(sub => {
if (sub && sub.external) {
subtitle = sub['external-filename']
}
return
}).catch(err => {}).finally(() => {
Cast.cast(player.name, title, url, subtitle)
})
},

keepWatchingPopup: () => {
Expand Down

0 comments on commit 686b3b8

Please sign in to comment.