xbmc.Player().play(): when do I need it?
#1
Hello everybody!

After reading the Kodi Addon Development documentation and different tutorials about how to develop video addons for Kodi, I'm a little confused about how exactly should I tell Kodi to playback movies if I have some URL to the video file.

After reading this awesome tutorial about setResolvedUrl() http://forum.kodi.tv/showthread.php?tid=...esolvedURL I realized how to tell Kodi to playback video file using some URL to the video file.

But what I do not understand is, what exactly do I need xbmc.Player().play() method for? What is the goal of it?
Reply
#2
setResolvedUrl() works only for plugins, while xbmc.Player().play() works for all types of add-ons. Also you cannot do anything after calling setResolvedUrl() while in some cases you need to do something after starting playback.
Also xbmc.Player can be sub-classed if you need to add or re-implement some methods to do specific tasks.
Reply
#3
Ok, I do understand now, there is the difference between setResolvedUrl and xbmc.Player().play() methods.

(2015-01-28, 15:26)Roman_V_M Wrote: setResolvedUrl() works only for plugins, while xbmc.Player().play() works for all types of add-ons. Also you cannot do anything after calling setResolvedUrl() while in some cases you need to do something after starting playback.

But could you please get some examples for cases where I need to do something after starting playback or probably some addons which use the xbmc.Player().play() method for playback video files?


Thank you!
Reply
#4
the main usage is for scripts which provide their own ui. they aren't simple a vfs like a plugin but implement the whole logic of 'what happens when a user clicks a thing in the list'.

a real-life example where you might want to do what roman outlines would be to load some subtitle.
Reply
#5
Well thank you very much for your explanation!

I would be very grateful if someone could tell me, why my code below playbacks videos only sometimes. But sometimes, if it's not it shows an error message "Playback failed. One or more items failed to play. Check the log file for details" In the log file it says:
Code:
ERROR: Playlist Player: skipping unplayable item: 0, path [plugin://plugin.video.my_plugin/?mode=playVideo&id=590]

Code:
def listVideos(category_id):
    videoList = getVideoList(category_id)
    for video in videoList["results"]:
        listItem = xbmcgui.ListItem(video["name"], iconImage="DefaultVideo.png", thumbnailImage="http://" + host + video["cover"])
        listItem.setProperty('IsPlayable', 'true')
        url = sys.argv[0] + "?" + urllib.urlencode({'mode': 'playVideo', 'id': video["id"].encode("utf8")})
        xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listItem, isFolder=False, totalItems=len(videoList["results"]))
    xbmcplugin.endOfDirectory(int(sys.argv[1]))

def playVideo(video_id):
    videoLink = getVideoLink(video_id)
    video_url = videoLink["results"]
    listItem = xbmcgui.ListItem("Tesfilm", path=video_url)
    xbmc.Player().play(item=video_url, listitem=listItem)

Thank you!
Reply
#6
Hi,

is it possible when I use the setResolvedUrl instead of Player.play so in subtitles dialog is not show the fileName?

Image
Reply

Logout Mark Read Team Forum Stats Members Help
xbmc.Player().play(): when do I need it?1