2011-07-11, 19:12
Im starting to write python scripts .. I found this guide in wiki :
http://wiki.xbmc.org/index.php?title=HOW...lay_A_File
i started with primitive script :
xbmc@XBMCLive:~/Videos$ more test.py
# variable to contain the file location
file = 'Reset_Sberna.mp3'
# tell xbmc to play our file we specified in the above variable
xbmc.Player().play(file)
after start im getting error :
xbmc@XBMCLive:~/Videos$ python test.py
Traceback (most recent call last):
File "test.py", line 4, in <module>
xbmc.Player().play(file)
NameError: name 'xbmc' is not defined
same with secondary example
xbmc@XBMCLive:~/Videos$ more test2.py
# Import XBMC module
import xbmc
# First we need to create an object containing the getMusicInfoTag() class from XBMC.Player().
# This is in order to use the same instance of the class twice and not create a new class
# for every time we query for information.
# This is a bit important to notice, as creating many instances is rarely
# a good thing to do (unless you need it, but not in this case).
tag = xbmc.Player().getMusicInfoTag()
# Now tag contains the getMusicInfoTag() class which then again contains song information.
# Now we use this object to get the data by calling functions within that class:
artist = tag.getArtist()
title = tag.getTitle()
# Now you have two strings containing the information. An example of what you could do next is to print it:
print "Playing: " + artist + " - " + title
# This will produce i.e: "Playing: AC/DC - Back in black"
xbmc@XBMCLive:~/Videos$ python test2.py
Traceback (most recent call last):
File "test2.py", line 2, in <module>
import xbmc
ImportError: No module named xbmc
What im doning wrong ?
http://wiki.xbmc.org/index.php?title=HOW...lay_A_File
i started with primitive script :
xbmc@XBMCLive:~/Videos$ more test.py
# variable to contain the file location
file = 'Reset_Sberna.mp3'
# tell xbmc to play our file we specified in the above variable
xbmc.Player().play(file)
after start im getting error :
xbmc@XBMCLive:~/Videos$ python test.py
Traceback (most recent call last):
File "test.py", line 4, in <module>
xbmc.Player().play(file)
NameError: name 'xbmc' is not defined
same with secondary example
xbmc@XBMCLive:~/Videos$ more test2.py
# Import XBMC module
import xbmc
# First we need to create an object containing the getMusicInfoTag() class from XBMC.Player().
# This is in order to use the same instance of the class twice and not create a new class
# for every time we query for information.
# This is a bit important to notice, as creating many instances is rarely
# a good thing to do (unless you need it, but not in this case).
tag = xbmc.Player().getMusicInfoTag()
# Now tag contains the getMusicInfoTag() class which then again contains song information.
# Now we use this object to get the data by calling functions within that class:
artist = tag.getArtist()
title = tag.getTitle()
# Now you have two strings containing the information. An example of what you could do next is to print it:
print "Playing: " + artist + " - " + title
# This will produce i.e: "Playing: AC/DC - Back in black"
xbmc@XBMCLive:~/Videos$ python test2.py
Traceback (most recent call last):
File "test2.py", line 2, in <module>
import xbmc
ImportError: No module named xbmc
What im doning wrong ?