 |
|
 |
im tryin to make an app that automatically adds new tracks to the library how do i search the current library to determin if the newly copied song already exists? 
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
 |
Hi all, Assume that a track that is in iPod is not in iTunes library(not in local machine also). Am using iTunes SDK to write my own app for streaming a track from iPod to PC. iTunes SDK provides API to play it directly thru iTunes. But can anyone tell me if iTunes is locally storing it somewhere while playing a track from iPod or does iTunes SDK exposes any API to do this? can I convert a track that is in iPod, say in protected AAC format to mp3 using iTunes SDK?
Halid Niyaz
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
It seems that the System.Windows.Forms.Timer doesn't work correctly if the form's not visible, but using a System.Timers timer fixes this issue....
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I tried using the eventhamdler and it didnt work. I was trying to update a label, like in the example, using pretty much the same code. This is what I used to set up the EventHandler iApp.OnPlayerPlayEvent += new _IiTunesEvents_OnPlayerPlayEventEventHandler(iApp_OnPlayerPlayEvent);
then this is the eventhandler i used: private void iApp_OnPlayerPlayEvent(object iTrack) { songTitle = ((IITTrack)iTrack).Name; songArtist = ((IITTrack)iTrack).Artist; songAlbum = ((IITTrack)iTrack).Album; SongName.Text = songTitle; TrackArtist.Text = songArtist; TrackAlbum.Text = songAlbum; this.Refresh(); }
But when the song changes it doesn't update the information. Does anybody have a solution? Thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I got same problem as you. And I find following way work.
iTunesAppClass myitunes = new iTunesAppClass();
...
void myitunes_OnPlayerPlayEvent(object iTrack) { IITTrack myTrack = myitunes.CurrentTrack; txtArtist.Text = myTrack.Artist; txtSong.Text = myTrack.Name; }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Not sure why, but calling code directly from the event handlers doesnt work, (i think it has something to do with the thread its being called from), but an easy way to make it work is to use the Form.Invoke() method to call another method to do the updating.
delegate void Router(object arg);
iTunes.OnPlayerPlayEvent += new _IiTunesEvents_OnPlayerPlayEventEventHandler( delegate(object o){ this.Invoke(new Router(iTunes_OnPlayerPlayEvent), o); });
void iTunes_OnPlayerPlayEvent(object iTrack) { MessageBox.Show("Player Event!"); }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
In order to get the Title/Artist update working correctly with VS 2005 and the .NET 2.0 Framework, I found I needed to add a line to the iTunesTray constuctor:
Label.CheckForIllegalCrossThreadCalls = false;
to prevent this new check from blocking the label text update. Just an FYI to anyone else seeing this problem.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I've tried adding that line of code on the constructor, but the events are still unhandled.
Did you come up with a solution for this problem?
I also tried Control.CheckForIllegalCrossThreadCalls = false; but it doesn't work either...
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Uhmm... looks that your solutionn is goo enought. Just make sure to use Control.CheckForIllegalCrossThreadCalls = false; for a more general solution.
I'm not quite sure, but I think the problem with events not handled is previous threads connected to iTunes Application that didn't close properly. This happens numerous times during development, and thus, iTunes won't fire any event to new instances of our application.
Does this make any sense at all? Hope it helps...
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I'm playing with the iTunes COM API via interop with some success. However, my app only works once per iTunes-process-lifetime. IE: I launch iTunes, then my app, and it works... close my app and start it again (without restarting iTunes) and my app doesn't receive events...
Do I have to do something nice when disconnecting from the iTunes API?
Any help greatly appreciated!
Drew Noakes drewnoakes.com
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi there! Probably you have already solved this issue now two years after you wrote it but for others battling with the same problem here is how I solved it.
It's easy actually, just release the iTunesAppClass like this!
System.Runtime.InteropServices.Marshal.ReleaseComObject(itunes);
Best regards /Peter Nylander
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Peter,
Actually I did fix this issue. I can't remember exactly how I did so now, though I don't think I used the Marshall class. Perhaps the object was disposable?
Actually I wanted to revisit my application as I believe the iTunes API provides more notifications of events these days, reducing the need for polling.
Best regards,
Drew Noakes.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Is it possible to get the "iTunes music folder" (define in "preferences"-->"advanced" of iTunes ) with that API ?
Thank you for your answer.
PS : sorry for my english, I'am french.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Sorry for the late reply.
It is not possible to get at this setting through the iTunes COM SDK. However, it might be possible to determine this based on the Registry, though my cursory search has turned up no promising results.
-- Adam
"If you can't beat your computer in chess, try kickboxing"
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Well, fisrt thank you for your answer... I haved search for finding it on the Registry too but I have'nt found any good result...So I don't kno w how to find it...So if you find any posibility... Ben
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Its in the Reg. Not sure under what key, but i'm using more then one software that knows to read it (Traktor etc).
Keep digging
Erikpro
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I am trying to use the iTunes API from C++ to manipulate playlists in iTunes. Does anyone know how I can add tracks to iTunes from a specific location and then get the IITTrack object corresponding to that Track?
What i want to do is set the play order of that track. But i need to get the IITTrack object to set the play order and i am not sure how i can do that. Any idea?
Sindhoor
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
I am currently writing a program in C++ which uses the iTunes COM interfaces from the iTunes COM SDK (http://developer.apple.com/sdk/itunescomsdk.html). I have found it easy to use IiTunes (CoInitialize(NULL); CoCreateInstance(CLSID_iTunesApp, NULL, CLSCTX_LOCAL_SERVER, IID_IiTunes, (PVOID *)&iITunes) , but using _IiTunesEvents poses some adversity. I would like the OnAboutToPromptUserToQuitEvent to call a function where I can run some cleanup code. How can I implement _IiTunesEvents? I am used to C# where I can use += easily, but it is my understanding that COM requires sinks and things of that sort.
I want to have something like this: IiTunes *iITunes = NULL; //make object bla bla bla ??????????(OnAboutToPromptUserToQuitEvent);
.....
HRESULT OnAboutToPromptUserToQuitEvent() { ..... }
Thanks, Jason A. Donenfeld ZX2C4 Software
|
| Sign In·View Thread·PermaLink | 4.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi ZX2C4, I know, the answer comes 2 years to late for you but i want to show my solution for this problem. (because i also was sitting a few days to get it ... and searching in the web for solutions^^)
#### in my main program: #### IConnectionPointContainer* icpc; IConnectionPoint* icp; CiTunesEventHandler* eventHandler; DWORD dwAdvise;
eventHandler = new CiTunesEventHandler(); piTunes->QueryInterface(IID_IConnectionPointContainer, (void **)&icpc); icpc->FindConnectionPoint(DIID__IiTunesEvents, &icp); icpc->Release(); icp->Advise(eventHandler,&dwAdvise); icp->Release(); #### end main ####
#### header of my CiTunesEventHandler class #### #include "iTunesCOMInterface.h"
class CiTunesEventHandler : public _IiTunesEvents { private: long m_dwRefCount; ITypeInfo* m_pITypeInfo; // Pointer to type information. public: CiTunesEventHandler(); ~CiTunesEventHandler();
HRESULT OnAboutToPromptUserToQuitEvent(); HRESULT OnPlayerPlayEvent(); //...and all the functions you want to use
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject); ULONG STDMETHODCALLTYPE AddRef(); ULONG STDMETHODCALLTYPE Release(); HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *){return E_NOTIMPL;}; HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT,LCID,ITypeInfo ** ){return E_NOTIMPL;}; HRESULT STDMETHODCALLTYPE GetIDsOfNames(const IID &,LPOLESTR * ,UINT,LCID,DISPID *){return E_NOTIMPL;}; HRESULT STDMETHODCALLTYPE Invoke(DISPID dispidMember, REFIID, LCID,WORD, DISPPARAMS* pdispparams, VARIANT*,EXCEPINFO*, UINT*); }; #### end header CiTunesEventHandler ####
#### implementation of CiTunesEventHandler #### CiTunesEventHandler::CiTunesEventHandler() { m_dwRefCount=0; ITypeLib* pITypeLib = NULL ; HRESULT hr = ::LoadRegTypeLib(LIBID_iTunesLib, 1, 5, 0x00, &pITypeLib) ; // Get type information for the interface of the object. hr = pITypeLib->GetTypeInfoOfGuid(DIID__IiTunesEvents, &m_pITypeInfo) ; pITypeLib->Release() ; }
CiTunesEventHandler::~CiTunesEventHandler() { }
HRESULT CiTunesEventHandler::OnAboutToPromptUserToQuitEvent() { //iTunes send OnAboutToPromptUserToQuitEvent return S_OK; }
HRESULT CiTunesEventHandler::OnPlayerPlayEvent() { //iTunes send OnPlayerPlayEvent return S_OK; }
HRESULT STDMETHODCALLTYPE CiTunesEventHandler::QueryInterface(REFIID iid, void **ppvObject) { if ((iid == IID_IDispatch)||(iid == DIID__IiTunesEvents)) { m_dwRefCount++; *ppvObject = this;//(_IiTunesEvents *)this; return S_OK; } if (iid == IID_IUnknown) { m_dwRefCount++; *ppvObject = this;//(IUnknown *)this; return S_OK; } return E_NOINTERFACE; }
ULONG STDMETHODCALLTYPE CiTunesEventHandler::AddRef(){ InterlockedIncrement(&m_dwRefCount); return m_dwRefCount; }
ULONG STDMETHODCALLTYPE CiTunesEventHandler::Release(){ InterlockedDecrement(&m_dwRefCount); if (m_dwRefCount == 0) { delete this; return 0; } return m_dwRefCount; }
HRESULT STDMETHODCALLTYPE CiTunesEventHandler::Invoke(DISPID dispidMember, REFIID, LCID,WORD, DISPPARAMS* pdispparams, VARIANT*,EXCEPINFO*, UINT*){ switch (dispidMember) //look in the documentation for "enum ITEvent" to get the numbers for the functions you want to implement { case 2: this->OnPlayerPlayEvent(); //this->OnPlayerPlayEvent((IITTrack*)&(pdispparams->rgvarg[0].pdispVal)); break; case 9: this->OnAboutToPromptUserToQuitEvent(); break; default: break; } return S_OK; } #### end implementation CiTunesEventHandler ####
the most helpful page for me, was this one: http://www11.ocn.ne.jp/~ikalu/cplus/5501.html (by the way: Thanks to the japanies )
In this way i choose, the function don't have to be named "OnPlayerPlayEvent" and so on... sounds funny (maybe it's not the correct way ) but that doesn't matter, because it works :-P
If you want to get in example the track with the OnPlayerPlayEvent... you must use something like this : "pdispparams->rgvarg[0].pdispVal" but I don't know exactly (I don't use them *g*)
This is a solution without using MFC 
greetz pVALIUM (sorry: if my english is not perfect, i am a German)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I'm trying to accomplish this in c++, and it's proving more difficult. Here is the my code:
hr = IiTunes->QueryInterface( IID_IConnectionPointContainer, (VOID**)&pContainer );
hr = pContainer->FindConnectionPoint( DIID__IiTunesEvents, &pConnectionPoint );
hr = pConnectionPoint->Advise(IiTunesEvents, pdwCookie);
IiTunesEvents is my class derived from _IiTunesEvents. All of the calls are successful expect the Advise() call. Does anyone know how to do this in c++?
Thanks, Matt Berube
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
I was eventually able to get this working, thanks to this[^] newsgroup thread. Here is my code:
CiTunesEventHandler m_eventHandler; CComPtr m_connectionPoint; CComQIPtr cpCont(IiTunes);
if (cpCont) { if (SUCCEEDED(cpCont->FindConnectionPoint(DIID__IiTunesEvents, &m_connectionPoint))) { m_connectionPoint->Advise(m_eventHandler.GetIDispatch(FALSE), &m_cookie); } } m_eventHandler.m_parent = m_hWnd; #include "iTunesCOMInterface.h" static const UINT UWM_ITUNESKEYS_PLAYER_PLAY_EVENT = ::RegisterWindowMessage(_T("UWM_ITUNESKEYS_PLAYER_PLAY_EVENT")); static const UINT UWM_ITUNESKEYS_PLAYER_STOP_EVENT = ::RegisterWindowMessage(_T("UWM_ITUNESKEYS_PLAYER_STOP_EVENT")); static const UINT UWM_ITUNESKEYS_ITUNESABOUTTOPROMPTUSERTOQUIT = ::RegisterWindowMessage(_T("UWM_ITUNESKEYS_ITUNESABOUTTOPROMPTUSERTOQUIT"));
class CiTunesEventHandler : public CCmdTarget { public: CiTunesEventHandler(); virtual ~CiTunesEventHandler();
public: HWND m_parent;
public:
public: virtual void OnFinalRelease(); DECLARE_MESSAGE_MAP() afx_msg void OnDatabaseChangedEvent(const VARIANT FAR& deletedObjectIDs, const VARIANT FAR& changedObjectIDs); afx_msg void OnPlayerPlayEvent(const VARIANT FAR& iTrack); afx_msg void OnPlayerStopEvent(const VARIANT FAR& iTrack); afx_msg void OnPlayerPlayingTrackChangedEv(const VARIANT FAR& iTrack); afx_msg void OnUserInterfaceEnabledEvent(); afx_msg void OnCOMCallsDisabledEvent(short reason); afx_msg void OnCOMCallsEnabled(); afx_msg void OnQuittingEvent(); afx_msg void OnAboutToPromptUserToQuitEvent(); afx_msg void OnSoundVolumeChangedEvent(long newVolume); DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP()
LPUNKNOWN GetInterfaceHook(const void *piid);
};
#include "stdafx.h" #include "iTunesEventHandler.h"
CiTunesEventHandler::CiTunesEventHandler() { EnableAutomation(); }
CiTunesEventHandler::~CiTunesEventHandler() { }
void CiTunesEventHandler::OnFinalRelease() { CCmdTarget::OnFinalRelease(); }
BEGIN_DISPATCH_MAP(CiTunesEventHandler, CCmdTarget) DISP_FUNCTION(CiTunesEventHandler, "OnDatabaseChangedEvent", OnDatabaseChangedEvent, VT_EMPTY, VTS_VARIANT VTS_VARIANT) DISP_FUNCTION(CiTunesEventHandler, "OnPlayerPlayEvent", OnPlayerPlayEvent, VT_EMPTY, VTS_VARIANT) DISP_FUNCTION(CiTunesEventHandler, "OnPlayerStopEvent", OnPlayerStopEvent, VT_EMPTY, VTS_VARIANT) DISP_FUNCTION(CiTunesEventHandler, "OnPlayerPlayingTrackChangedEv", OnPlayerPlayingTrackChangedEv, VT_EMPTY, VTS_VARIANT) DISP_FUNCTION(CiTunesEventHandler, "OnUserInterfaceEnabledEvent", OnUserInterfaceEnabledEvent, VT_EMPTY, VTS_NONE) DISP_FUNCTION(CiTunesEventHandler, "OnCOMCallsDisabledEvent", OnCOMCallsDisabledEvent, VT_EMPTY, VTS_I2) DISP_FUNCTION(CiTunesEventHandler, "OnCOMCallsEnabled", OnCOMCallsEnabled, VT_EMPTY, VTS_NONE) DISP_FUNCTION(CiTunesEventHandler, "OnQuittingEvent", OnQuittingEvent, VT_EMPTY, VTS_NONE) DISP_FUNCTION(CiTunesEventHandler, "OnAboutToPromptUserToQuitEvent", OnAboutToPromptUserToQuitEvent, VT_EMPTY, VTS_NONE) DISP_FUNCTION(CiTunesEventHandler, "OnSoundVolumeChangedEvent", OnSoundVolumeChangedEvent, VT_EMPTY, VTS_I4) END_DISPATCH_MAP()
static const IID IID_IiTunesEventHandler = { 0x429dd3c8, 0x703e, 0x4188, { 0x96, 0xe, 0xa9, 0x82, 0x1f, 0x14, 0xb0, 0x4c } };
BEGIN_INTERFACE_MAP(CiTunesEventHandler, CCmdTarget) INTERFACE_PART(CiTunesEventHandler, IID_IiTunesEventHandler, Dispatch) END_INTERFACE_MAP()
LPUNKNOWN CiTunesEventHandler::GetInterfaceHook(const void *piid) { REFIID iid = *(IID *) piid; if (iid == DIID__IiTunesEvents) return GetIDispatch(FALSE); else return NULL; }
void CiTunesEventHandler::OnDatabaseChangedEvent(const VARIANT & , const VARIANT & ) { }
void CiTunesEventHandler::OnPlayerPlayEvent(const VARIANT& ) { PostMessage(m_parent, UWM_ITUNESKEYS_PLAYER_PLAY_EVENT, 0, 0); }
void CiTunesEventHandler::OnPlayerStopEvent(const VARIANT& ) { PostMessage(m_parent, UWM_ITUNESKEYS_PLAYER_STOP_EVENT, 0, 0); }
void CiTunesEventHandler::OnPlayerPlayingTrackChangedEv(const VARIANT & ) { }
void CiTunesEventHandler::OnUserInterfaceEnabledEvent() { }
void CiTunesEventHandler::OnCOMCallsDisabledEvent(short ) { }
void CiTunesEventHandler::OnCOMCallsEnabled() { }
void CiTunesEventHandler::OnQuittingEvent() { }
void CiTunesEventHandler::OnAboutToPromptUserToQuitEvent() { PostMessage(m_parent, UWM_ITUNESKEYS_ITUNESABOUTTOPROMPTUSERTOQUIT, 0, 0); }
void CiTunesEventHandler::OnSoundVolumeChangedEvent(long ) { }
|
| Sign In·View Thread·PermaLink | 4.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
Hi, in the thread above "Re: Itunes COM Events" i just have written, is my solution without using MFC  greetz pVALIUM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |