[python-win32] iTunes COM using Python win32
Adrien LINA
adrienlina at gmail.com
Thu Mar 24 17:57:58 CET 2011
Hello, I came across the same problem as you.
I googled my problem and i found the answer, when you create a playlist, it
is 'only' an IITPlaylist.
In opposition with the IITUserPlaylist, you are unable to use the method
"Addtrack(the_track)".
This is why you need to 'populate' it, using the instance
"win32com.client.CastTo(the_playlist, 'IITUserPlaylist')"
Here is my test code, in case I was unclear ^^
import win32com.client
iTunes = win32com.client.gencache.EnsureDispatch("iTunes.Application")
library = iTunes.LibraryPlaylist
tracks = library.Tracks
nouvelle_playlist = iTunes.CreatePlaylist('test')
nouvelle_playlist = iTunes.CreatePlaylist('Deselected Albums')
nouvelle_playlist = win32com.client.CastTo(nouvelle_playlist,
'IITUserPlaylist')
third_track=tracks[100]
nouvelle_playlist.AddTrack(third_track)
nouvelle_playlist.PlayFirstTrack()
Glad I helped.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20110324/71c67b34/attachment.html>
More information about the python-win32
mailing list