I’m trying to create a simple Kodi plugin that plays a local video file. The code below is a simplified version of a larger project where I’m trying to play m3u8 streams. This code doesn’t work and I can’t figure out why. The logs don’t contain any errors, but the video doesn’t play. Can you please help me identify the problem?
Here is my code:
python:
import sys
import xbmc
import xbmcaddon
import xbmcgui
import xbmcplugin
import os
xbmc.log(f"START", level=xbmc.LOGDEBUG)
url = sys.argv[0]
addon = xbmcaddon.Addon()
addon_path = addon.getAddonInfo('path')
def play_local_video(video_path):
list_item = xbmcgui.ListItem(path=video_path)
xbmc.log(f"{list_item}", level=xbmc.LOGDEBUG)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, list_item)
def main():
addon = xbmcaddon.Addon()
local_video_path = os.path.join(addon_path, 'video168.ts')
play_local_video(local_video_path)
if __name__ == '__main__':
main()
Thanks for any advice!
What did you try and what were you expecting? I followed the basic steps to set up a Kodi plugin and wrote a function to play a local video file. Specifically, I:
Initialized the addon and retrieved its path using xbmcaddon.Addon(). Constructed the path to the local video file. Created a ListItem with the video path. Used xbmcplugin.setResolvedUrl to attempt to play the video. I expected the local video file video168.ts to start playing when the plugin was executed. Instead, the video doesn’t play, and there are no errors in the Kodi logs that explain why.