adding subtitles to videos - creating addon
#1
Hello,

I've just rewrote my script from using xbmcswift2 to more native no framework addon. I wanted to add subtitles to my videos. I have a function that pre downloads subtitles to my addon folder and names it xxx.srt

what will be the line to use to add it to the video so that it will automatically add the subtitle into the video ?

TIA
Reply
#2
https://github.com/amet/script.xbmc.subt...ui.py#L341
Reply
#3
so for my function that calls and plays the video i have
Code:
def play(url, play=False):
    playlist = xbmc.PlayList(1)
    playlist.clear()
    thumb=''
    info = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=thumb)
    playlist.add(url, info)
    fname="sub.srt"
    subtitle=xbmc.translatePath( os.path.join( home, fname ))
    xbmc.Player().setSubtitles(subtitle.encode("utf-8"))
    xbmc.Player().play(playlist)

the subs get generated from a different function that gets called before this and i've tested the srt thats being generated by manually adding it to the sub and it works fine however i want the video to play with the subtitles already attached and the above does not do that..




actually i think its solved..

i just reversed the order and now it seems to work

Code:
    xbmc.Player().play(playlist)
    xbmc.Player().setSubtitles(subtitle.encode("utf-8"))

Reply
#4
Code:
xbmc.Player().play(playlist)
xbmc.Player().setSubtitles(subtitle.encode("utf-8"))

Reply
#5
Thanks amet.. came to the same conclusion!
Reply

Logout Mark Read Team Forum Stats Members Help
adding subtitles to videos - creating addon0