2009-08-31 50 views
5

如何使用COM在Windows上使用COM在iTunes中创建播放列表(在Windows上不使用AppleScript)?使用COM和Java在iTunes中创建播放列表

我已经找到了库here,做大多数的我需要什么,我已经加入了一些代码ITPlaylist.java,调用“AddTrack法”(提到in the docs)在iTunes对象ITPlaylist:

public void addTrack(ITTrack track) { 
    ITPlaylistKind k = getKind(); 
    if (k == ITPlaylistKindUser) { 
     Dispatch.put(object, "AddTrack", track); 
    } else 
     throw new UnsupportedOperationException("can only add track to user playlists - kind : " + k); 
} 

但我得到一个错误:

# A fatal error has been detected by the Java Runtime Environment: 
# 
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x1000e150, pid=3184, tid=3896 
# 
# JRE version: 6.0_15-b03 
# Java VM: Java HotSpot(TM) Client VM (14.1-b02 mixed mode, sharing windows-x86) 
# Problematic frame: 
# C [jacob-1.14.3-x86.dll+0xe150] 
# 
# An error report file with more information is saved as: 
# Z:\\hs_err_pid3184.log 
# 
# If you would like to submit a bug report, please visit: 
# http://java.sun.com/webapps/bugreport/crash.jsp 
# The crash happened outside the Java Virtual Machine in native code. 
# See problematic frame for where to report the bug. 

当我尝试调用此方法。日志文件包含:

# 
# A fatal error has been detected by the Java Runtime Environment: 
# 
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x1000e150, pid=3040, tid=3756 
# 
# JRE version: 6.0_15-b03 
# Java VM: Java HotSpot(TM) Client VM (14.1-b02 mixed mode, sharing windows-x86) 
# Problematic frame: 
# C [jacob-1.14.3-x86.dll+0xe150] 
# 
# If you would like to submit a bug report, please visit: 
# http://java.sun.com/webapps/bugreport/crash.jsp 
# The crash happened outside the Java Virtual Machine in native code. 
# See problematic frame for where to report the bug. 
# 

--------------- T H R E A D --------------- 

Current thread (0x01ed1400): JavaThread "main" [_thread_in_native, id=3756, stack(0x003b0000,0x00400000)] 

siginfo: ExceptionCode=0xc0000005, reading address 0x00000005 

Registers: 
EAX=0x00000000, EBX=0x0490f6f8, ECX=0x003ffd8c, EDX=0x240b14e8 
ESP=0x003ff9d0, EBP=0x003ffa14, ESI=0x01ed1510, EDI=0x00000005 
EIP=0x1000e150, EFLAGS=0x00010246 

Top of Stack: (sp=0x003ff9d0) 
0x003ff9d0: 01ed1400 28404d90 28404d90 01fd9e27 
0x003ff9e0: 01ed1510 003ffa28 003ffa24 01ed1400 
0x003ff9f0: 2840bbaf 003ff9f4 00000000 003ffa28 
0x003ffa00: 28409fb8 00000000 28404d90 00000000 
0x003ffa10: 003ffa24 003ffa4c 01fd2da1 00000000 
0x003ffa20: 01fd8259 240b14e8 240b39d8 003ffa2c 
0x003ffa30: 2840401a 003ffa58 28409fb8 00000000 
0x003ffa40: 28404040 003ffa24 003ffa54 003ffa7c 

Instructions: (pc=0x1000e150) 
0x1000e140: 1d 53 ff 15 20 01 01 10 66 c7 03 09 00 89 7b 08 
0x1000e150: 8b 0f 8b 51 04 57 ff d2 5f 5e 5b c2 0c 00 6a ff 


Stack: [0x003b0000,0x00400000], sp=0x003ff9d0, free space=318k 
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) 
C [jacob-1.14.3-x86.dll+0xe150] 
j com.jacob.com.Variant.putObject(Ljava/lang/Object;)V+2 
j com.jacob.com.VariantUtilities.populateVariant(Lcom/jacob/com/Variant;Ljava/lang/Object;Z)V+511 
j com.jacob.com.VariantUtilities.objectToVariant(Ljava/lang/Object;)Lcom/jacob/com/Variant;+248 
j com.jacob.com.VariantUtilities.objectsToVariants([Ljava/lang/Object;)[Lcom/jacob/com/Variant;+19 
j com.jacob.com.Dispatch.invoke(Lcom/jacob/com/Dispatch;Ljava/lang/String;I[Ljava/lang/Object;[I)Lcom/jacob/com/Variant;+8 
j com.jacob.com.Dispatch.put(Lcom/jacob/com/Dispatch;Ljava/lang/String;Ljava/lang/Object;)V+18 
j com.dt.iTunesController.ITPlaylist.addTrack(Lcom/dt/iTunesController/ITTrack;)V+19 
j uk.co.teamnomad.itunes.WindowsLibraryImpl.savePlaylist(Ljava/util/List;Luk/co/teamnomad/itunes/PlayList;)V+46 
j uk.co.teamnomad.bpm.main.Main.<init>(Luk/co/teamnomad/bpm/system/OperatingSystem;)V+309 
j uk.co.teamnomad.bpm.main.Main.getInstance()Luk/co/teamnomad/bpm/main/Main;+16 
j uk.co.teamnomad.bpm.main.Main.main([Ljava/lang/String;)V+8 
v ~StubRoutines::call_stub 
V [jvm.dll+0xecfac] 
V [jvm.dll+0x1741d1] 
V [jvm.dll+0xed02d] 
V [jvm.dll+0xf5bf5] 
V [jvm.dll+0xfd84d] 
C [java.exe+0x2155] 
C [java.exe+0x82ce] 
C [kernel32.dll+0x44911] 
C [ntdll.dll+0x3e4b6] 
C [ntdll.dll+0x3e489] 

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) 
j com.jacob.com.Variant.putVariantDispatch(Ljava/lang/Object;)V+0 
j com.jacob.com.Variant.putObject(Ljava/lang/Object;)V+2 
j com.jacob.com.VariantUtilities.populateVariant(Lcom/jacob/com/Variant;Ljava/lang/Object;Z)V+511 
j com.jacob.com.VariantUtilities.objectToVariant(Ljava/lang/Object;)Lcom/jacob/com/Variant;+248 
j com.jacob.com.VariantUtilities.objectsToVariants([Ljava/lang/Object;)[Lcom/jacob/com/Variant;+19 
j com.jacob.com.Dispatch.invoke(Lcom/jacob/com/Dispatch;Ljava/lang/String;I[Ljava/lang/Object;[I)Lcom/jacob/com/Variant;+8 
j com.jacob.com.Dispatch.put(Lcom/jacob/com/Dispatch;Ljava/lang/String;Ljava/lang/Object;)V+18 
j com.dt.iTunesController.ITPlaylist.addTrack(Lcom/dt/iTunesController/ITTrack;)V+19 
j uk.co.teamnomad.itunes.WindowsLibraryImpl.savePlaylist(Ljava/util/List;Luk/co/teamnomad/itunes/PlayList;)V+46 
j uk.co.teamnomad.bpm.main.Main.<init>(Luk/co/teamnomad/bpm/system/OperatingSystem;)V+309 
j uk.co.teamnomad.bpm.main.Main.getInstance()Luk/co/teamnomad/bpm/main/Main;+16 
j uk.co.teamnomad.bpm.main.Main.main([Ljava/lang/String;)V+8 
v ~StubRoutines::call_stub 

--------------- P R O C E S S --------------- 

Java Threads: (=> current thread) 
    0x043a4800 JavaThread "MerapiBridgeSocket" [_thread_in_native, id=3664, stack(0x04800000,0x04850000)] 
    0x01f4c800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=2440, stack(0x04160000,0x041b0000)] 
    0x01f47c00 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3628, stack(0x04110000,0x04160000)] 
    0x01f47400 JavaThread "Attach Listener" daemon [_thread_blocked, id=3584, stack(0x040c0000,0x04110000)] 
    0x01f3ac00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=2968, stack(0x04070000,0x040c0000)] 
    0x01ef8c00 JavaThread "Finalizer" daemon [_thread_blocked, id=3724, stack(0x04020000,0x04070000)] 
    0x01ef7800 JavaThread "Reference Handler" daemon [_thread_blocked, id=3324, stack(0x03fd0000,0x04020000)] 
=>0x01ed1400 JavaThread "main" [_thread_in_native, id=3756, stack(0x003b0000,0x00400000)] 

Other Threads: 
    0x01ef6000 VMThread [stack: 0x01180000,0x011d0000] [id=2836] 
    0x01f5f000 WatcherThread [stack: 0x041b0000,0x04200000] [id=3528] 

VM state:not at safepoint (normal execution) 

VM Mutex/Monitor currently owned by a thread: None 

Heap 
def new generation total 960K, used 794K [0x24000000, 0x24100000, 0x244e0000) 
    eden space 896K, 81% used [0x24000000, 0x240b7510, 0x240e0000) 
    from space 64K, 95% used [0x240f0000, 0x240ff450, 0x24100000) 
    to space 64K, 0% used [0x240e0000, 0x240e0000, 0x240f0000) 
tenured generation total 4096K, used 876K [0x244e0000, 0x248e0000, 0x28000000) 
    the space 4096K, 21% used [0x244e0000, 0x245bb318, 0x245bb400, 0x248e0000) 
compacting perm gen total 12288K, used 4255K [0x28000000, 0x28c00000, 0x2c000000) 
    the space 12288K, 34% used [0x28000000, 0x28427cb8, 0x28427e00, 0x28c00000) 
    ro space 8192K, 63% used [0x2c000000, 0x2c519920, 0x2c519a00, 0x2c800000) 
    rw space 12288K, 53% used [0x2c800000, 0x2ce74dd0, 0x2ce74e00, 0x2d400000) 

Dynamic libraries: 
0x00400000 - 0x00424000  C:\Windows\system32\java.exe 
0x771a0000 - 0x772c7000  C:\Windows\system32\ntdll.dll 
0x75a20000 - 0x75afb000  C:\Windows\system32\kernel32.dll 
0x75ee0000 - 0x75fa6000  C:\Windows\system32\ADVAPI32.dll 
0x772e0000 - 0x773a3000  C:\Windows\system32\RPCRT4.dll 
0x7c340000 - 0x7c396000  C:\Program Files\Java\jre6\bin\msvcr71.dll 
0x6d800000 - 0x6da8b000  C:\Program Files\Java\jre6\bin\client\jvm.dll 
0x77060000 - 0x770fd000  C:\Windows\system32\USER32.dll 
0x773b0000 - 0x773fb000  C:\Windows\system32\GDI32.dll 
0x744f0000 - 0x74522000  C:\Windows\system32\WINMM.dll 
0x76f30000 - 0x76fda000  C:\Windows\system32\msvcrt.dll 
0x76d20000 - 0x76e64000  C:\Windows\system32\ole32.dll 
0x75d20000 - 0x75dad000  C:\Windows\system32\OLEAUT32.dll 
0x744b0000 - 0x744e9000  C:\Windows\system32\OLEACC.dll 
0x77100000 - 0x7711e000  C:\Windows\system32\IMM32.DLL 
0x76c00000 - 0x76cc8000  C:\Windows\system32\MSCTF.dll 
0x75820000 - 0x7584c000  C:\Windows\system32\apphelp.dll 
0x772d0000 - 0x772d9000  C:\Windows\system32\LPK.DLL 
0x77120000 - 0x7719d000  C:\Windows\system32\USP10.dll 
0x6d7b0000 - 0x6d7bc000  C:\Program Files\Java\jre6\bin\verify.dll 
0x6d330000 - 0x6d34f000  C:\Program Files\Java\jre6\bin\java.dll 
0x6d290000 - 0x6d298000  C:\Program Files\Java\jre6\bin\hpi.dll 
0x75a10000 - 0x75a17000  C:\Windows\system32\PSAPI.DLL 
0x6d7f0000 - 0x6d7ff000  C:\Program Files\Java\jre6\bin\zip.dll 
0x6d610000 - 0x6d623000  C:\Program Files\Java\jre6\bin\net.dll 
0x76e70000 - 0x76e9d000  C:\Windows\system32\WS2_32.dll 
0x75fb0000 - 0x75fb6000  C:\Windows\system32\NSI.dll 
0x75030000 - 0x7506b000  C:\Windows\system32\mswsock.dll 
0x75090000 - 0x75095000  C:\Windows\System32\wship6.dll 
0x74cf0000 - 0x74cf5000  C:\Windows\System32\wshtcpip.dll 
0x10000000 - 0x10019000  C:\Windows\System32\jacob-1.14.3-x86.dll 
0x72640000 - 0x726db000  C:\Windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.1434_none_d08b6002442c891f\MSVCR80.dll 
0x76ea0000 - 0x76f24000  C:\Windows\system32\CLBCatQ.DLL 
0x74db0000 - 0x74deb000  C:\Windows\system32\rsaenh.dll 

VM Arguments: 
java_command: bpm-0.0.13-jar-with-dependencies.jar 
Launcher Type: SUN_STANDARD 

Environment Variables: 
CLASSPATH=.;C:\Program Files\QuickTime\QTSystem\QTJava.zip 
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\QuickTime\QTSystem\ 
USERNAME=ed 
OS=Windows_NT 
PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 6, GenuineIntel 



--------------- S Y S T E M --------------- 

OS: Windows Vista Build 6001 Service Pack 1 

CPU:total 1 (2 cores per cpu, 1 threads per core) family 6 model 23 stepping 6, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1 

Memory: 4k page, physical 2097151k(1656488k free), swap 4194303k(4092420k free) 

vm_info: Java HotSpot(TM) Client VM (14.1-b02) for windows-x86 JRE (1.6.0_15-b03), built on Jul 25 2009 01:22:46 by "java_re" with MS VC++ 7.1 

time: Mon Aug 31 20:14:48 2009 
elapsed time: 7 seconds 

我在做什么错?

+0

我很想看到这个工作,但我不相信苹果不打破版本之间的接口。确保你的COM库与安装的iTunes的确切版本一起工作。 – Karl 2009-08-31 17:28:34

+0

@Karl:我尝试过的所有其他调用似乎工作正常,我可以创建播放列表,但我无法添加曲目给他们。 – l0st3d 2009-08-31 17:31:01

+0

日志文件(在Z:\ hs_err_pid3184.log)中说什么?有任何线索吗? – 2009-08-31 19:02:14

回答

1

答案对我来说,是联系我正在使用的图书馆的开发人员,让他发布图书馆的新版本。如果你想这样做,那么至少使用0.2版本,它将正确区分ITPlaylist对象和ITUserPlaylist对象,这些对象(如lurkingfridge79所提到的,是唯一可以通过COM API添加到它们的轨道的播放列表)

+0

你是否尝试做一个演员,如我所说的?我很好奇,看看它是否会起作用,或者它是否会对COM桥做些有趣的事... – 2009-09-01 19:30:56

+0

不,对不起,我没有 - 在我回到SO之前已经有了更新的库并看到你的回复。我不确定它会工作。 – l0st3d 2009-09-01 19:36:26

+0

经过上面的回复,我认为几乎肯定会失败。很高兴看到有更新的图书馆! – 2009-09-01 19:46:23

1

我没有在Java中做过任何iTunes的东西一段时间,但从我有什么经验我记得,接口可以是变幻莫测。

我没有任何确定的答案,但为了在黑暗中提供至少一个镜头,也许你应该尝试将你正在使用的ITPlaylist投射到一个ITUserPlaylist(当然这是正确的类型)然后调用 addTrack方法。这样您就可以使用库提供的功能,如果这样做不起作用,您可以与开发人员联系,因为可能会出现更严重的问题。

从您提供的转储中,看起来好像JACOB中的底层C正试图通过iTunes COM接口修改等价的ITPlaylist。这可能是因为继承的方式? IE:ITPlaylist不支持addTrack(底层C正试图调用一个不存在的函数),但是ITUserPlaylist呢?只是一个想法。

建议修正:

public void addTrack(ITTrack track) { 
    ITPlaylistKind k = getKind(); 
    if (k == ITPlaylistKindUser) { 
     Dispatch.put(((ITUserPlaylist)this).object, "AddTrack", track); 
    } else 
     throw new UnsupportedOperationException("can only add track to user playlists - kind : " + k); 
} 

再次声明,我绝对不是专家在这里,如果任何人有任何更好的想法,请继续前进,在我后:)

让我知道你的提议你任何成功!

编辑 重新阅读我的文章,我才意识到我忘了这个方法,这可能可以说是更好,因为它使JACOB COM桥出更高层次的东西后:

((ITUserPlaylist)this).addTrack(track); 
+0

我已经投票给你了,因为你看起来非常正确,在你阅读这个问题时,但我并不真正了解你的建议更正。未传递到COM API中的java对象的类型(它仅包含那个对象)会如何影响iTunes的行为。 – l0st3d 2009-09-01 19:34:03

+0

@ l0st3d我对你使用的库不太熟悉(我从来没有在iTunes上使用JACOB上的任何东西),所以我不确定库在实现这些对象时究竟在做什么,或者对象的派发来自何处。实际上,我们希望尽量减少使用ITUserPlaylist的addTrack方法来消除用户错误,并将其缩小到API,这显然已经完成了。对不起,如果我发布了任何可能令人困惑的内容,只是觉得自从我之前经历过这些尴尬以后,我可能会提供帮助。 – 2009-09-01 19:42:56

+0

@ lurkingfridge79 - 任何和所有的帮助表示赞赏:) – l0st3d 2009-09-01 19:53:43

相关问题