0

I need to open itunes using System.Diagnostic.Start using C# Code. Is this possible?

Also I need to pass the song or Video to play when I open itune.

If i use this code this does opens the song, but it open it with the default player of my system. I want to open this song with itune only.

System.Diagnostics.Process.Start(@"G:\My music\7.mp3");

Is this possible?

Pankaj
  • 1,446
  • 4
  • 19
  • 31
  • change the default application to open song to itunes... http://support.apple.com/kb/HT3202 – PawanS Aug 02 '13 at 09:35
  • yes i know .. in this way it's working.... but i dont want user to change his or her default choice... – Pankaj Aug 02 '13 at 09:38
  • Can you run the following command from windows command prompt. `START c:\progra~1\iTunes\iTunes.exe "your MP3.mp3"` – PawanS Aug 02 '13 at 10:01

2 Answers2

0

The only way I can see this working is if you dig around the users file system in the obvious places for a iTunes install or search the registry for the path.

As a last resort you can always ask the user for the path to iTunes then you can call the process that way with iTunes as the application.

Process.Start("c:\progra~1\iTunes\iTunes.exe", "W:\Radio\BBC Radio 1\Zane Lowe\Zane Lowe.mp3");

That should do it

owenrumney
  • 1,520
  • 3
  • 18
  • 37
  • if by some way i get the itunes to get opened still i wont be able to play the desired song.The song to be play is stored in XML file, – Pankaj Aug 02 '13 at 09:46
  • I thought you were trying to open the process with a .mp3 file, not xml file – owenrumney Aug 02 '13 at 09:50
  • I am trying to open a mp3 file only.... for the time being just forget about xml file(it is just an alternative plan).... What i want is some thing like this.... process.start(itunes, songname).... is something like this is possible – Pankaj Aug 02 '13 at 09:53
  • well its not working... it does open up the itunes... but it start playing first song of the play list the code i used is Process.Start(@"C:\Program Files (x86)\iTunes\iTunes.exe", @"G:\My music\7.mp3"); – Pankaj Aug 02 '13 at 10:01
0

If you want to show the open with prompt to user so that he/she can choose the desired application then try this link

You can also edit the registry to set the default program to run. Try to update the registry key .MP3 to open with iTunes only through your code. You can get the reg details at this link

I can't give you exact solution but this is the hint and I believe you can do this.

PawanS
  • 7,033
  • 14
  • 43
  • 71