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.
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to