Help opening specific file.
#1
I'm far from an expert when it comes to json and python files just curious if anyone knows of an easy way to create a python or json file to open a specific file on the same computer that my kodi is installed on i tried the following code but it doesnt play the file, not sure if im missing something or not.

import xbmc

# variable to contain the file location
file = 'C:\Users\Media Center\Downloads\PawPatrol\pawpat1x2.mp4'
# tell xbmc to play our file we specified in the above variable
xbmc.Player().play(file)



I also tried it without the import xbmc up at the top. I have no other xbmc python files running or working on matching so not sure if i should have downloaded something else or not to get all this to work properly.

Thanks in advance.
Reply
#2
Varian 1.

import xbmcgui, xbmcplugin

# Get handle ...
try : HANDLE = int(sys.argv[1])
except : HANDLE = -1

# Set listitem ...
filePath = 'C:\\Users\\Media Center\\Downloads\\PawPatrol\\pawpat1x2.mp4'
fileLI = xbmcgui.ListItem (path=filePath)
fileLI.setProperty('IsPlayable', 'true')

# Play ...
xbmcplugin.setResolvedUrl(HANDLE, True, fileLI)

Varian 2.

import xbmc, xbmcgui

player = xbmc.Player()
# or with core : player = xbmc.Player(xbmc.PLAYER_CORE_AUTO) for kodi 16, player = xbmc.Player(xbmc.PLAYER_CORE_VideoPlayer) for 17

filePath = 'C:\\Users\\Media Center\\Downloads\\PawPatrol\\pawpat1x2.mp4'
listitem = xbmcgui.ListItem (path=filePath)

player.play(filePath, listitem)
Reply

Logout Mark Read Team Forum Stats Members Help
Help opening specific file.0