Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,491 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,286 people online right now. Registration is fast and FREE... Join Now!




iTunes system commands

 
Reply to this topicStart new topic

iTunes system commands, How do I get it to play?

Mattman573
24 Feb, 2007 - 04:09 PM
Post #1

New D.I.C Head
*

Joined: 24 Feb, 2007
Posts: 2


My Contributions
Hey guys,

I made an alarm for myself using C, and I want to get iTunes to play when the countdown is up. I can get it to open using the system call, but I don't know the system commands to get it to do anything. Could you let me know, or point me to a list of commands?

Thanks!

CODE
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
    time_t    time_now;
    struct tm *time_ptr;
    double start = 0;
    int hours = 0;
    int minutes = 0;
    int seconds = 0;
    double end = 0;
    
    printf("How many hours from now do you want to wake up?-->");
    scanf("%i", &hours);
    printf("How many minutes from now do you want to wake up?-->");
    scanf("%i", &minutes);
    printf("How many seconds from now do you want to wake up?-->");
    scanf("%i", &seconds);
    
    end = (hours*3600) + (minutes*60) + seconds;
    
    fflush(stdin);
    
    start=time(&time_now);
    while(time(&time_now)< start+end)
    {
            system("cls");
            printf("%s\n\n", asctime(localtime(&time_now)));
    }
    system("C:\\PROGRA~1\\iTunes\\itunes.exe");
    return(0);
}

User is offlineProfile CardPM
+Quote Post

NickDMax
RE: ITunes System Commands
24 Feb, 2007 - 04:17 PM
Post #2

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,867



Thanked: 53 times
Dream Kudos: 550
My Contributions
I am shooting from the hip here, but would it work to just pass the file name to it?
CODE
system("C:\\PROGRA~1\\iTunes\\itunes.exe C:\\music\\Beegees\\MoreThanaWoman.mp3");


though it might not be the best idea to hard code in the file name... especialy that one. smile.gif
User is offlineProfile CardPM
+Quote Post

Mattman573
RE: ITunes System Commands
24 Feb, 2007 - 04:32 PM
Post #3

New D.I.C Head
*

Joined: 24 Feb, 2007
Posts: 2


My Contributions
QUOTE(NickDMax @ 24 Feb, 2007 - 05:17 PM) *

I am shooting from the hip here, but would it work to just pass the file name to it?
CODE
system("C:\\PROGRA~1\\iTunes\\itunes.exe C:\\music\\Beegees\\MoreThanaWoman.mp3");


though it might not be the best idea to hard code in the file name... especialy that one. smile.gif



Haha, yeah that's what I have right now, but I'm really looking for it playing a playlist or "Party Shuffle".
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: ITunes System Commands
24 Feb, 2007 - 05:56 PM
Post #4

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,867



Thanked: 53 times
Dream Kudos: 550
My Contributions
Well I think you can pass the playlist just like you can the .mp3 file name. As for setting shuffle or what-not with iTunes I can't really say. However your program can be written in VBScript and you can use SendKeys to control iTunes.

I know that winamp has a progamable API (application programing interface). I saw a student project that allowed you to use a remote with winamp and media player.

IF you wanted to get into windows programming you can of course send messages to iTunes and hack your way to what you need. There are a lot of message spy programs (spy++ supplied with VS for example) which can allow you to peek in and see what messages are sent when you click on different buttons.
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: ITunes System Commands
24 Feb, 2007 - 07:56 PM
Post #5

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 4,026



Thanked: 38 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
I'm pretty sure ITunes has an API too, although most of it is undocumented. We'll need to study the exports section of the DLL Files it uses to get to know what functions are available.

But the safest method would be to pass the playlist path as a command line argument.
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: ITunes System Commands
24 Feb, 2007 - 08:17 PM
Post #6

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,867



Thanked: 53 times
Dream Kudos: 550
My Contributions
QUOTE(born2c0de @ 24 Feb, 2007 - 08:56 PM) *

I'm pretty sure ITunes has an API too, although most of it is undocumented. We'll need to study the exports section of the DLL Files it uses to get to know what functions are available.


lol, being Mac-ware I didn't even think about it. It honestly never crossed my mind to hack the API, I just though about messages.

QUOTE
iTunes COM for Windows SDK (ZIP)
267 KB 2004-11-08
This SDK provides header files, documentation, and sample JScript files demonstrating how to use the iTunes for Windows COM interface. COM is the Microsoft technology, similar to AppleScript on Mac OS, that allows programmatic control of iTunes from languages like JScript, Visual Basic, C#, and C++. This SDK requires iTunes for Windows version 4.7 or later.


This might help
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/7/09 05:39PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month