New to XBMC (but not python), problems writing a simple video plugin to learn API
#1
hey all, i'm looking to write a video plugin for watching/streaming FLV files from a particular website.

since i haven't messed with the XBMC API before, i wanted to start by simply just playing a local video first, then grow the plugin by streaming it from their site, then expand it more by listing the available videos to stream. so as a first run, i've written the simplest plugin that i can think of.

Code:
import xbmc

if ( __name__ == "__main__" ):
  xbmc.Player(xbmc.PLAYER_CORE_MPLAYER).play( "/Users/keith/Downloads/1192.flv" )

what happens here is that when i run my plugin from the videos menu, the first frame of the video loads and the audio starts playing correctly. but after that the video does not play and XBMC locks up (the audio continues but the app in un-responsive). i am forced to force quit XBMC (OS X Leopard) i also tried all the other player types (auto, dvdplayer, etc) and they all display the same behavior. this is with XBMC 9.04

i then tried putting the file into my videos directory to just play the file through XBMC normally. this works fine. the video plays normally and the interface (pause, menu, etc) work.

my question is: is there something fundamentally wrong with my script that would make playback not work correctly? i did not see anything in the docs about needing any other setup API calls before playing a video.

thanks!
Reply
#2
afex2win Wrote:hey all, i'm looking to write a video plugin for watching/streaming FLV files from a particular website.

since i haven't messed with the XBMC API before, i wanted to start by simply just playing a local video first, then grow the plugin by streaming it from their site, then expand it more by listing the available videos to stream. so as a first run, i've written the simplest plugin that i can think of.

Code:
import xbmc

if ( __name__ == "__main__" ):
  xbmc.Player(xbmc.PLAYER_CORE_MPLAYER).play( "/Users/keith/Downloads/1192.flv" )

what happens here is that when i run my plugin from the videos menu, the first frame of the video loads and the audio starts playing correctly. but after that the video does not play and XBMC locks up (the audio continues but the app in un-responsive). i am forced to force quit XBMC (OS X Leopard) i also tried all the other player types (auto, dvdplayer, etc) and they all display the same behavior. this is with XBMC 9.04

i then tried putting the file into my videos directory to just play the file through XBMC normally. this works fine. the video plays normally and the interface (pause, menu, etc) work.

my question is: is there something fundamentally wrong with my script that would make playback not work correctly? i did not see anything in the docs about needing any other setup API calls before playing a video.

thanks!

It sounds like a playback problem, not a scripting problem. Try removing xbmc.PLAYER_CORE_MPLAYER and let xbmc decide what player to use.

Code:
import xbmc

if ( __name__ == "__main__" ):
  xbmc.Player().play( "/Users/keith/Downloads/1192.flv" )

Edit: I didn't notice at first but it looks like you already tried that... to answer your question though, no there is nothing fundamentally wrong with your code.

I'm curious, could you try making a playlist of just that one video then playing that?
Always read the XBMC online-manual, FAQ and search and search the forum before posting.
For troubleshooting and bug reporting please read how to submit a proper bug report.

If you're interested in writing addons for xbmc, read docs and how-to for plugins and scripts ||| http://code.google.com/p/xbmc-addons/
Reply
#3
@afex2win
Being that you are writing a video plugin, normally that return a list of entries to display for the user to choose to play. I found that you may need to end the directory listing with:

xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )

succeeded should be true when you have entries to be displayed, false when you want to return to the previous entry - see if it works.

See the documentation here:
http://xbmc.sourceforge.net/python-docs/
Reply
#4
Dan Dare Wrote:@afex2win
Being that you are writing a video plugin, normally that return a list of entries to display for the user to choose to play. I found that you may need to end the directory listing with:

xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )

succeeded should be true when you have entries to be displayed, false when you want to return to the previous entry - see if it works.

See the documentation here:
http://xbmc.sourceforge.net/python-docs/

thanks! a cursory glance shows that the video plays and the menu controls work now. i want to make sure i understand exactly why this worked, let me know if this is wrong:

in a normal video plugin, the first screen usually shown is the listing of available videos. at the end of this execution, the endOfDirectory method should be called. so normally you always at least have one endOfDirectory call happening before trying to play a video.

do you happen to know exactly why play relies on endOfDirectory?
Reply
#5
That's the thing, I don't know :-) One of us should report this as a bug, maybe XBMC developers would be able to find an explanation. Recently I wrote the Sublight plugin and in order to get the length of the video in seconds I had to call the Player() to play the video and then stop it - I found that sometimes it worked, but most of the times it locked.

Other times I found that plugins locked cause they didn't "end" the directory listing with either True (when having entries) or False (no entries, to return gracefuly), so maybe it's something to keep in mind.

rwparris2, any thoughts?
Reply
#6
i see Big Grin

i'll just have to keep trying things out to figure out the nuances of the API.

by the way, where can i find the error log for python scripts on Mac OSX?
Reply
#7
Now, this may not be correct, but according to this wiki page (http://wiki.xbmc.org/?title=HOW-TO_insta...irectories), the plugins have to be installed in ~/Library/Application Support/XBMC/plugins/.../, therefore I fair guess would be to look in ~/Library/Application Support/XBMC/ for xbmc.log.

Otherwise you can view the errors by going into the Scripts in XBMC and press "i", that should bring up the Scripts output (may not be easy to navigate after a while though). I usually develop my plugins on Windows and I use Notepad++ which can reload the xbmc.log. I actually use Eclipse with PyDev to write the plugins, if you are Python beginner might want to look into that, it helps with the file management, SVN/CVS client, basic Python errors and syntax hightlight - in fact the Eclipse editor allows to reload the xbmc.log on change as well, I just seem to like Notepad++ for some reason :-)
Reply
#8
found it, the error log on mac osx is located at:

/Users/<user>/Library/Logs/xbmc.log
Reply

Logout Mark Read Team Forum Stats Members Help
New to XBMC (but not python), problems writing a simple video plugin to learn API0