How to set title for streamed media ?
#1
My plugin jworg on github load a list of mp4 file.

When at the end the user choose a title and a resolution from a select list, I do
Code:
xbmc.Player(xbmc.PLAYER_CORE_AUTO).play(mp4_to_play[selected])

Where mp4_to_play[index] is a full url of a .mp4 file.

The problem is that the mp4 name is ugly. So when playing a video, I see not the title (that I grab from a json), but I see instead the file name.

So I've the title,
Image


but results is like this
Image

Is there a way when invoking play method to set up the title of the stream ?
Reply
#2
This should work:
Code:
listitem = xbmcgui.ListItem('STREAM_TITLE')
xbmc.Player().play(STREAM_URL, listitem)
Reply
#3
if you're calling player in a plugin you are doing it wrong.
Reply
#4
Thanks to both.

Please, @spiff, tell me what's the right way to launch the player from a select list, don't limit yourself to tell me wha'ts wrong !
Reply
#5
I think, spiff wanted to say that you should use setResolvedUrl() instead of Player().play()...

Code:
listitem = xbmcgui.ListItem(path='STREAM_URL')
listitem.setInfo(type='Video', infoLabels={'Title':'STREAM_TITLE'})
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)

You normally don't need to set the title, it uses the title from the selected listitem.
Reply
#6
Sorry, I not understand.

I read the doc about setResolvedUrl. It tells: "Callback function to tell XBMC that the file plugin has been resolved to a url".

I don't understand what the goal of this function... sorry.



My code is here
Code:
    options = []
    mp4_to_play = []
    for mp4 in json["files"][language_code]["MP4"]:
        url = mp4["file"]["url"]
        mp4_to_play.append(url);

        res = mp4["label"]
        title = "[" + res + "] - " + mp4["title"]
        options.append(title.encode('utf8'))

    # Choose format and specific video
    dia = xbmcgui.Dialog()
    string = jw_config.t(30007)
    selected = dia.select(string, options)
    if selected != -1 :
        print "JWORG I'll play " + mp4_to_play[selected]
        xbmc.Player(xbmc.PLAYER_CORE_AUTO).play(mp4_to_play[selected])

How do I integrate your 3 rows code with mine ?

I tried this, but after I select a video from popup list, I got an empty page, the video is NOT played
Code:
if selected != -1 :
        listitem = xbmcgui.ListItem(path=mp4_to_play[selected])
        listitem.setInfo(type='Video', infoLabels={'Title': mp4_titles[selected] })
        xbmcplugin.setResolvedUrl(jw_config.pluginPid, True, listitem)
        xbmc.Player(xbmc.PLAYER_CORE_AUTO).play(mp4_titles[selected], listitem)


I redesigned, removed the popup list and done this:
Code:
for ...
        listItem = xbmcgui.ListItem(label=title)
        listItem.setInfo(type='Video', infoLabels={'Title': title })

        xbmcplugin.addDirectoryItem(
            handle=jw_config.pluginPid,
            url=url,
            listitem=listItem,
            isFolder=False )  

    xbmcplugin.endOfDirectory(handle=jw_config.pluginPid)

In this way it works, and I see video title, good.

Is it a good way ? This is my first plugin and it's important I learn nest practive just now, because this plugin will become really big "as time goes by"
Reply
#7
- CUT -
Reply
#8
(2013-09-20, 09:57)realtebo Wrote: Is it a good way ? This is my first plugin and it's important I learn nest practive just now, because this plugin will become really big "as time goes by"

Yes, this is the way to go. Note that you also can set the thumbnail/icon, studio and some other (skin dependent) tags this way! But generally this isn't needed during the setResolvedUrl()-call because the previously selected ListItem should already have all InfoLabels set.

If you really plan to make it "really big", consider migrating it to the xbmcswift2 add-on framework.
For some examples have a look to my github page:

The code of Apple iTunes Trailers should be easy to read and understand
The Music Add-on JamBMC is quite complex.


Good luck!
My GitHub. My Add-ons:
Image
Reply
#9
Thanks for all

I warn you that the link to xmbcswift2 doesn't work

For framework: no, thanks, it will not use it. Not for my first plugin. I'm a experienced php programmer, and I think I'll create my code tool to get code reusability and I'll grow my code readabilty commit by commit.

But thanks for demo links: an example link is more valuable than a milion of words
Reply
#10
Link fixed, thanks (btw. your link to your github repo in first post does not work also Tongue).

Sure, doing it "raw" a good way to learn the basics...
My GitHub. My Add-ons:
Image
Reply
#11
Fixed ! Wink
Reply

Logout Mark Read Team Forum Stats Members Help
How to set title for streamed media ?0