python adjustments
#1
hi just poking around in the python api,
and was a little amazed about something.
it seems we have api to turn the playlist shuffle on, but non to turn it off.
and it would be nice if the randomize playlist was exposed too.

Smile

shuffle example:
http://home.no.net/thor918/xbmc/stuff/shuffle.spy



Reply
#2
can you compile your own?

if so i think you just need to send it to the existing unshuffle() function. in pyplaylist.cpp copy all the shuffle() stuff and change it to unshuffle() or i can send you the pyplaylist.cpp file.

it compiles, but i haven't tested it.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#3
sure can compile.
but sourcechanging :p i'm not sure if i'm so good at.
but if it works, post the patch file.

if it's as simple as you say, i may give it ago.
can't see where you get the unshuffle from.
what file did you find that it was that?



Reply
#4
shuffle() and unshuffle() are in playlist.cpp.

pyplaylist.cpp already includes playlist.h so all i did was copy the existing shuffle() and change it to unshuffle().

i can send you pyplaylist.cpp, but it isn't hard to change.

i can't test it right now. if you could test it and it works you could submit the patch or i can whichever works for you. it's just the one file. i won't submit it until i know it works.

it goes in xbmc\lib\libpython\xbmcmodule\

here's a link to the file. pyplaylist.cpp



For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#5
i see it now Wink
wonder where the random function is.
perhaps that is more work to do.
Reply
#6
i edited the link above.

what's the difference between random and shuffle?
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#7
hehe.
well random, will make the media in the playlist randomized positions,
while the shuffle will not touch the playlist, just jump.

so if you use the randomize function, the next in the playlist, will be the next song listed.

----
i have edited the file now. added unshuffle + unshuffle doc
i'm compiling a fresh build right now.



Reply
#8
a quick look, the only difference between randomize() in fileitem.cpp and shuffle() is m_bshuffled = true;

i'm thinking your descriptions are reversed. since selecting shuffle on load for playlists, the lists are shuffled.

so i guess a randomize() could be added to playlist.cppHuh it would be shuffle() minus m_bshuffled = true;? or maybe include fileitem.h

i could see the use for that. i'm not sure what's the best way to do it though.



For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#9
you where right it was the oposite descriptions on those two.
anyway, the unshuffle seems to work here. Wink
but both seems to delay in updating.
if i use the shuffle/unshuffle in gui, the change takes effect at once, but doing it trough python, it will take one "play next" before it will do what it supose to do.
Reply
#10
it may need to be reset()?

if you submit a patch, the pydoc for unshuffle should be moved down just above the unshuffle object. i messed that up.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#11
for some reson, my cvs software gives error when i try to make patch file.something must be wrong with my setup.
but i was able to create a diff file.

http://home.no.net/thor918/xbmc/stuff/unshuffle.diff
Reply
#12
edit: deleted, bad change.



For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#13
i tested the shuffle and unshuffle and it appears to take effect immediately.

how did you test it?



For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#14
i tested this using these:
http://home.no.net/thor918/xbmc/stuff/shuffle.spy
http://home.no.net/thor918/xbmc/stuff/unshuffle.spy
http://10.0.1.9/xbmccmds/xbmchttp?comman...tlyplaying
http://10.0.1.9/xbmccmds/xbmchttp?command=playnext

well after what i can read off, there is something wrong.
but since your tests shows it's working on spot, i'm a little unshure.
here is some data i wrote down.
http://home.no.net/thor918/xbmc/stuff/shuffletests2.txt

well from my testings now. the shuffle sems to be right on, but the unshuffle is not.
but maby i'm just doing the tests wrong.



Reply
#15
this is what i used.
i queued three songs to the now playing and stopped playback. i then ran the following script.
Quote:import xbmc

plist = xbmc.playlist(0)
plist.shuffle()
xbmc.player().play(plist)
print xbmc.player().getplayingfile()
xbmc.player().playnext()
print xbmc.player().getplayingfile()
xbmc.player().playnext()
print xbmc.player().getplayingfile()
xbmc.player().stop()

i alway got shuffled results.

i then tried the unshuffle and it always started playing the first song and ordered them properly. so i think it works right. do you want me to submit a patch?

by the way do you know how to get the following to work for playlist(), i couldn't.

Quote:use playlist[int position] or --getitem--(int position) to get a playlistitem.



For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply

Logout Mark Read Team Forum Stats Members Help
python adjustments0