[plt-scheme] MysterX generates an error when accessing a property

From: Justin Zamora (justin at zamora.com)
Date: Fri Oct 5 17:42:36 EDT 2007

I am writing a program that uses MysterX to access iTunes's COM
scripting interface, and when I access a certain property, MysterX is
returning an error stating that it can't allocate the return value.
Here's a snippet that demonstrates the problem (it assumes there is a
video file with the name "mysterx" in your iTunes library; the type of
video doesn't seem to matter; I've tested both MPEG-1 files and mp4
files with the same results):

(require (lib "mysterx.ss" "mysterx"))
(require (lib "class.ss"))
(define iTunes (begin (display "Connecting to iTunes...") (cci/coclass
"iTunes Class")))
(define library-playlist (com-get-property iTunes "LibraryPlaylist"))
(define tracks (com-get-property library-playlist "Tracks"))
(define t (com-get-property tracks '("ItemByName" "mysterx")))
(com-get-property t "VideoKind")
. Can't allocate return value for VARIANT 0x401D

The iTunes COM SDK documentation states that the VideoKind property
accessor returns the following enumeration type:
   enum ITVideoKind
      Specifies the video track kind (added in iTunes type library 1.8).

   Enumeration values:
      ITVideoKindNone  (0) Not a video track, or unknown video track kind.
      ITVideoKindMovie  (1) Movie video track.
      ITVideoKindMusicVideo  (2) Music video track.
      ITVideoKindTVShow  (3) TV show video track.

I checked that MysterX understands that VideoKind is an enumeration
using com-get-property-type:

> (com-get-property-type t "VideoKind")
(-> com-enumeration)

So MysterX seems to understand that it's an enumeration, but it gives
the "Can't allocate return value for VARIANT 0x401D" error when I
access the property.  Other properties (like "Name", "Artist",
"Album", "Kind") work correctly, but "VideoKind" produces the error.

The equivalent JScript code works correctly (it displays "1", the
numeric value of ITVideoKindMovie):

var	iTunesApp = WScript.CreateObject("iTunes.Application");
var	mainLibrary = iTunesApp.LibraryPlaylist;
var	tracks = mainLibrary.Tracks;
var	t = tracks.ItemByName("mysterx");

Is this a bug in MysterX or can I do something to make this work?  I
am using DrScheme 371 and iTunes


Posted on the users mailing list.