-1

Don know how to go about this. I have about 12 videos which has to be added to the player and play on after the other. Right now only one video is getting played.

Following is the piece of code :

Process proc = new Process ();
foreach (string videos in Directory.GetFiles(Application.streamingAssetsPath)) 
{
    filePath = Path.Combine (Application.streamingAssetsPath, videos);
    proc.StartInfo.FileName = filePath; 
    proc.Start ();
}

I printed and checked files in proc.StartInfo.FileName , all the 12 videos are getting printed.But don't know how to load them into the player.

Xaruth
  • 4,034
  • 3
  • 19
  • 26
Vivek Kalkur
  • 2,200
  • 2
  • 21
  • 40

1 Answers1

1

We need more details to help you out !

What video player are you using ?

Since your code starts multiple processes (bad idea IMO) and you see only one, I can assume that your player can only have one instance running and it is used again, hence you do only see one video.

Potential answer:

Probably your player accepts multiple arguments, I'll take the example of Winamp :

winamp.exe "d:\f1 race - Copy.wav" "d:\f1 race.wav"

This will start an instance of Winamp and all the files will be on the playlist.

enter image description here

EDIT

The same applies to WMP as well :

wmplayer.exe "d:\f1 race - Copy.wav" "d:\f1 race.wav"

enter image description here

Playing a folder containing medias :

It does work with Winamp but not with WMP unfortunately, so passing each media full path as above seems the only solution for WMP. I'm not sure about the maximum length you can throw as arguments since it is not explicitly said in here.

You might wonder why dropping a folder to WMP effectively loads all the files in it ? They for sure do get all the files from the path you have dropped and add them to the playlist.

Alternatives

Maybe you should define a list of the installed media players that the user would choose the one he prefers to use. (and define a default one, in this case WMP is a good choice since there's a strong probability it is installed on the system)

You can retrieve a default application for a particular extension, see the following links :

Finding the default application for opening a particular file type on Windows

http://windevblog.blogspot.fr/2008/09/get-default-application-in-windows-xp.html

There is also the DropTarget route though it might not be straightforward, here's a sample from MSDN : http://msdn.microsoft.com/en-us/library/windows/desktop/dd940354(v=vs.85).aspx

I strongly suggest you to take a look at this small piece of software that helps in seeing/browsing/editing the default applications for a particular extension : http://defaultprogramseditor.com/ (must run as admin)

enter image description here

Community
  • 1
  • 1
aybe
  • 15,516
  • 9
  • 57
  • 105
  • I am using Windows Media Player, could you kindly suggest some good idea if this was a bad idea, I mean no harsh here. What would be the alternate method to load all the videos present in a particular folder and load them into the video player? – Vivek Kalkur Mar 14 '14 at 08:49