SageTV Community  

Go Back   SageTV Community > SageTV Customizations > SageTV Customizations

SageTV Customizations This forums is for discussing and sharing user-created modifications for the SageTV application created by using the SageTV Studio or through the use of external plugins. Use this forum to discuss customizations for SageTV version 6 and earlier, or for the SageTV3 UI.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-16-2004, 09:57 PM
sleight42's Avatar
sleight42 sleight42 is offline
Sage Advanced User
 
Join Date: Jun 2004
Location: Vienna, VA
Posts: 148
Open Request for iTunes Integration Assistance

Guys,

Having poked through Nielm's menu XML, I decided to do a little research into the possibility of integrating iTunes support directly into Sage.

I believe as of iTunes 4.5, Apple has made an iTunes API available. Evidentally, the Windows iTunes comes with a built in COM API. At a glance, the API looks extremely robust.

Therefore, it should be extremlely possible to write JScripts, invoked as Action Menu Items through Nielm's menu system, to exercise near or full control over iTunes through Sage.

Here's how I believe this could work:
1. Nielm action menu item executes COM program containing various commands to iTunes (e.g., connecting to a library to extract a list of songs by a particular artist)
2. Sage menu item execution blocks waiting for JScript to complete execution
3. COM program generates results into XML and exits
4. Sage loads afforementioned XML and throws data upon the screen.

I believe that I can handle steps 1 through 3. What I need is someone who can make a front end for this puppy assuming that I can demonstrate that steps 2 is as feasable as I predict.

Any takers?

I'm psyched!

__________________
SageTV Server, P4 2.4Ghz, 1GB RAM, RAID 5 3x250GB Serial-ATA HDD and 1 x 200GB, Sony DRU-700 DVD Writer, MCE 250, 100GB ethernet, Win XP Pro
Apple Airport Extreme Base Station
Apple Airport Express as range extender
SageTV Client, Shuttle SN41G2V2, Athlon 2500+ XP Barton, 512MB RAM, 40GB HDD, ATI9600 128MB, Linksys 802.11g, Win XP Pro, Sonic decoder
SageTV Client, Shuttle SN41G2V2, Athlon 1200, 512MB RAM, 40GB HDD, Linksys 802.11g, Win XP Pro, Sonic decoder

Last edited by sleight42; 10-16-2004 at 11:51 PM.
Reply With Quote
  #2  
Old 10-16-2004, 11:42 PM
rich_l rich_l is offline
Sage User
 
Join Date: Sep 2004
Posts: 66
This is awesome. Unfortunately, programming is not my specialty. I really hope you find someone to get this to work.
Reply With Quote
  #3  
Old 10-17-2004, 12:05 AM
sleight42's Avatar
sleight42 sleight42 is offline
Sage Advanced User
 
Join Date: Jun 2004
Location: Vienna, VA
Posts: 148
Ok. Found a Java-COM bridge. The stub generator doesn't work as happily as I'd hoped, gen'ing methods of void type for attribute accessors. Feh. Perhaps I'm doing something wrong with the stub generator but it seems simple enough for a trained monkey like me. At least I can use it to invoke on iTunes dynamically at runtime; I just don't get the nice compile-time checking.

Short version: I was able to write a very simple Java program that successfully extracted and printed the name of my iTunes Library from a Java class. This looks like it will be doable...
__________________
SageTV Server, P4 2.4Ghz, 1GB RAM, RAID 5 3x250GB Serial-ATA HDD and 1 x 200GB, Sony DRU-700 DVD Writer, MCE 250, 100GB ethernet, Win XP Pro
Apple Airport Extreme Base Station
Apple Airport Express as range extender
SageTV Client, Shuttle SN41G2V2, Athlon 2500+ XP Barton, 512MB RAM, 40GB HDD, ATI9600 128MB, Linksys 802.11g, Win XP Pro, Sonic decoder
SageTV Client, Shuttle SN41G2V2, Athlon 1200, 512MB RAM, 40GB HDD, Linksys 802.11g, Win XP Pro, Sonic decoder
Reply With Quote
  #4  
Old 10-17-2004, 01:53 AM
sleight42's Avatar
sleight42 sleight42 is offline
Sage Advanced User
 
Join Date: Jun 2004
Location: Vienna, VA
Posts: 148
I now have a test case where I can interrogate iTunes for all of its libraries, local and shared (i.e., libraries from other iTunes instances on a LAN), can interrogate all of the above for play lists, and can instruct the local iTunes instance to play the first track.

Unfortunately, the remote iTunes instances still must be manually connected (by clicking on them in iTunes) in order for them to be visible to me. Still looking for a workaround. It'd be a huge bummer if you had to click in iTunes to let Sage play songs out of a remote iTunes instance. Any suggestions?


Boy, it sure would be nice if I could get JAWIN to correctly generate COM stubs. I've been writing my own wrappers around the JAWIN classes to get to the underlying COM library. Sure, I could write this ugly but then there would be no hope of me or anyone else ever being able to reuse the work.

Now, do I have a taker out there or do I need to post some Java code to convince folks? Getting it running is a little bit of a pain as you need JAWIN installed. That is, if you need to see this in action to believe it.

This could all be accomplished a bit easier in JScript. However, I wanted a pure Java solution as it makes barfing out XML later quite a bit easier on me.

Damn, but this hack is addictive. My wife will kill me tomorrow for not getting enough sleep but I can't make myself stop...
__________________
SageTV Server, P4 2.4Ghz, 1GB RAM, RAID 5 3x250GB Serial-ATA HDD and 1 x 200GB, Sony DRU-700 DVD Writer, MCE 250, 100GB ethernet, Win XP Pro
Apple Airport Extreme Base Station
Apple Airport Express as range extender
SageTV Client, Shuttle SN41G2V2, Athlon 2500+ XP Barton, 512MB RAM, 40GB HDD, ATI9600 128MB, Linksys 802.11g, Win XP Pro, Sonic decoder
SageTV Client, Shuttle SN41G2V2, Athlon 1200, 512MB RAM, 40GB HDD, Linksys 802.11g, Win XP Pro, Sonic decoder

Last edited by sleight42; 10-17-2004 at 02:51 AM.
Reply With Quote
  #5  
Old 10-17-2004, 04:33 AM
sleight42's Avatar
sleight42 sleight42 is offline
Sage Advanced User
 
Join Date: Jun 2004
Location: Vienna, VA
Posts: 148
Must... sleep... (even though I'm not tired because I've been too focused on this).

Seriously, though, I now have a simple "PlaylistLauncher" class that can locate a play list, by name, across multiple iTunes libraries, local and remote, and play it from the first track.

Here are the limitations that I've encountered:
1. Cannot connect to remote iTunes w/o user having started local iTunes and manually clicking on remote iTunes in source list to establish connectivity. In fact, on query, iTunes doesn't even list the remote library until I've connected. It's as though it doesn't exist. However, WRT to the GUI, the remote iTunes is visible in the source list. Clearly, this is something that they do behind the scenes and likely don't expose intentionally because of the scandal surrounding iCommune.
2. Once connected to remote (shared) library, cannot access the main library. However, I can access all of its playlists. If I "standardize" on a play list called "All Songs" (requiring users to create a play list of that name and dumping everything that they want to expose to Sage within), I ought to be able to search and play from the remote library at will once the connection to the remote library is established (see hurdle 1). I can already play by playlist name. Searching within a playlist appears to be trivial.

Haven't played with extracting information from iTunes during execution (i.e., currently playing song, play time into current song, etc).

The API is pretty simple to use now that I have a knack for using JAWIN w/o its generated wrappers (*sigh*).

So, any suggestions on how to detect that shared/remote iTunes library?
__________________
SageTV Server, P4 2.4Ghz, 1GB RAM, RAID 5 3x250GB Serial-ATA HDD and 1 x 200GB, Sony DRU-700 DVD Writer, MCE 250, 100GB ethernet, Win XP Pro
Apple Airport Extreme Base Station
Apple Airport Express as range extender
SageTV Client, Shuttle SN41G2V2, Athlon 2500+ XP Barton, 512MB RAM, 40GB HDD, ATI9600 128MB, Linksys 802.11g, Win XP Pro, Sonic decoder
SageTV Client, Shuttle SN41G2V2, Athlon 1200, 512MB RAM, 40GB HDD, Linksys 802.11g, Win XP Pro, Sonic decoder
Reply With Quote
  #6  
Old 10-17-2004, 09:51 AM
stanger89's Avatar
stanger89 stanger89 is offline
SageTVaholic
 
Join Date: May 2003
Location: Marion, IA
Posts: 14,371
sleight,

Well first I'll have to say good luck with Java+COM, just curious which bridge are you using? Jacob? We (salsbst and I, well, mostly salsbst) tried that but found it didn't work well, memory freeing problems.

Anyway, before you get too far, you might want to see if JRMC can do what you want.
__________________
Aspect Ratio 101
Reply With Quote
  #7  
Old 10-17-2004, 10:04 AM
sleight42's Avatar
sleight42 sleight42 is offline
Sage Advanced User
 
Join Date: Jun 2004
Location: Vienna, VA
Posts: 148
Maybe you didn't make it through all of my rambling above.

I'm using jawin. Found it after a bit of googling last night. It's supposed to generate stubs around the COM API to allow for compile time checking of your COM code. Unfortunately, this didn't play too well with iTunes for me. However, underneath the hood, it does have a dynamic, if ugly, API. It really doesn't look all that much different than the JScript that I could've even more easily have written. But, then, I don't think that I'd want to try to gen XML within JScript. For example:

Code:
/*
 * Created on Oct 17, 2004
 */
package com.sleight42.itunes.com;

import org.jawin.COMException;
import org.jawin.DispatchPtr;

public class Playlist extends Dispatcher {

    /**
     * @param ptr
     * @throws COMException
     */
    public Playlist(PlaylistCollection collection, int index) throws COMException {
        super(collection.ptr_.getObject("Item", new Integer(index)));
    }
    
    /**
     * @param tunes
     * @throws COMException
     */
    public Playlist(ITunes tunes) throws COMException {
        super(tunes.ptr_.getObject("LibraryPlaylist"));
    }

    public String getName() throws COMException {
        return (String) ptr_.get("Name");
    }
    
    public long getDuration() throws COMException {
        return ((Long) ptr_.get("Duration")).longValue();
    }
    
    public void playFirstTrack() throws COMException {
        ptr_.invoke("PlayFirstTrack");
    }
}
This is my (work in progress) wrapper around an iTunes Playlist COM interface. Again, jawin should've gen'd something like this for me. For whatever reason, it had issues.

My main problem is that the iTunes COM API seems a bit limited (almost certainly intentionally). I'd really prefer to use it as a server, running in the background and invisible to the user. Unfortunately, I belive that's exactly what Apple is trying to prevent me from doing.

I'm still in the "poke and prod" mode, trying to figure out just how much I can get away with.

WRT to JRMC, looks nice but I have all of my music on my media server downstairs. I do most of my viewing off of my client. That and I have some (although not a ton) of encrypted AACs from the iTunes Store that would be nice to have in the living room.

I'd noticed that salbst had written a framework for JRMC when I peeked at the Sage Plugin CVS. Didn't even know what JRMC was at the time.
__________________
SageTV Server, P4 2.4Ghz, 1GB RAM, RAID 5 3x250GB Serial-ATA HDD and 1 x 200GB, Sony DRU-700 DVD Writer, MCE 250, 100GB ethernet, Win XP Pro
Apple Airport Extreme Base Station
Apple Airport Express as range extender
SageTV Client, Shuttle SN41G2V2, Athlon 2500+ XP Barton, 512MB RAM, 40GB HDD, ATI9600 128MB, Linksys 802.11g, Win XP Pro, Sonic decoder
SageTV Client, Shuttle SN41G2V2, Athlon 1200, 512MB RAM, 40GB HDD, Linksys 802.11g, Win XP Pro, Sonic decoder

Last edited by sleight42; 10-17-2004 at 10:11 AM.
Reply With Quote
  #8  
Old 10-17-2004, 10:33 AM
salsbst's Avatar
salsbst salsbst is offline
SageTVaholic
 
Join Date: Jun 2003
Posts: 2,592
sleight, too bad you're an iTunes guy, sounds like you are trying to do the same thing we are, just with a different product.

The biggest problem I had with jacob was threading related -- the memory usage was annoying but manageable. If you don't hit the wrapper from multiple threads you probably won't have any issues.

Quote:
WRT to JRMC, looks nice but I have all of my music on my media server downstairs. I do most of my viewing off of my client.
This seems like a good reason to use JRMC, not a reason not to do so. Perhaps I misunderstand you.

Quote:
That and I have some (although not a ton) of encrypted AACs from the iTunes Store that would be nice to have in the living room.
Well that is an issue. Please, I beg you to help stem the tide... do not purchase any more encrypted music! Show 'em who's boss!

Anyway, good luck with your project.
Reply With Quote
  #9  
Old 10-17-2004, 10:43 AM
sleight42's Avatar
sleight42 sleight42 is offline
Sage Advanced User
 
Join Date: Jun 2004
Location: Vienna, VA
Posts: 148
I'm playing with JRMC at the moment and, barring the lack of my few AACs, it works fine.

If I really wanted my AACs in MP3, all that I would have to do is burn them to CD, rerip them in MP3s, and I'm golden. No worries. I don't have that many.

So how can I help you and Stranger? I saw your JRMC framework in the CVS...
__________________
SageTV Server, P4 2.4Ghz, 1GB RAM, RAID 5 3x250GB Serial-ATA HDD and 1 x 200GB, Sony DRU-700 DVD Writer, MCE 250, 100GB ethernet, Win XP Pro
Apple Airport Extreme Base Station
Apple Airport Express as range extender
SageTV Client, Shuttle SN41G2V2, Athlon 2500+ XP Barton, 512MB RAM, 40GB HDD, ATI9600 128MB, Linksys 802.11g, Win XP Pro, Sonic decoder
SageTV Client, Shuttle SN41G2V2, Athlon 1200, 512MB RAM, 40GB HDD, Linksys 802.11g, Win XP Pro, Sonic decoder
Reply With Quote
  #10  
Old 10-17-2004, 11:12 AM
stanger89's Avatar
stanger89 stanger89 is offline
SageTVaholic
 
Join Date: May 2003
Location: Marion, IA
Posts: 14,371
FWIW, I believe that JRMC is supposed to be able to play files from iTMS, not sure if you need to have iTunes on the same machine or what...

See here:
http://yabb.jriver.com/interact/inde...5052#msg165052
__________________
Aspect Ratio 101
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 11:45 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.