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.
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.
EDIT
The same applies to WMP as well :
wmplayer.exe "d:\f1 race - Copy.wav" "d:\f1 race.wav"
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)
Related
Is it possible to play a specific audio object in Wwise without having a separate event for it? I'm implementing a dialogue system, and I have thousands of audio clips for dialogues, and making an event for each and every one would be extremely time consuming and error prone and impossible to maintain.
So either play an audio object from a bank directly or somehow giving the event an argument as to which object to play (I know that goes against the idea of events and the fact that the caller shouldn't know exactly what clip is going to be played).
Use Wwise External Source plugin, described relatively well here. The docs on this feature are not the best, but the general workflow I used went something like this:
Stored voice over files outside the Wwise project and Unity streaming assets folder (could be anywhere, I used a folder next to the Assets folder)
Create a new Voice audio object in Wwise and add an External Source to it (edit the audio object, click "Add Source" and select External Source)
Wrote a simple python script to generate a .wsources XML file that reads all the files in the voice files folder
Add the .wsources file to the external sources in Project Settings in Wwise
Post the event from Unity with path being whatever you used as "Destination" in the .wsources file, ie. it's not an absolute path
in my uwp app I am getting video files from KnownFolder.VideoLibrary and I am using QueryOptions to get them, so taking advantage of that I am trying to use AdvancedQuerySyntax so that I only get video files, but I am actually getting subtitle files like srt as well. what am I doing wrong here? is the AQS syntax I wrote wrong? I think subs files are also considered as video files according to this syntax, is there a way I can narrow it down to getting only video files excluding subtitle files? or can I get a link to docs where I can know what is the list of extension types, this syntax actually will return? So I can manage it accordingly?
CODE
videoFileOptions = new QueryOptions()
{
IndexerOption = IndexerOption.OnlyUseIndexerAndOptimizeForIndexedProperties//check sort order later
};
string videoFilter = "System.Kind:=System.Kind#Video";
videoFileOptions.ApplicationSearchFilter += videoFilter;
videoFileOptions.SetPropertyPrefetch(PropertyPrefetchOptions.VideoProperties, RequiredVideoProperties);
videoFileOptions.SetThumbnailPrefetch(ThumbnailMode.VideosView, thumbnailRequestedSize, ThumbnailOptions.UseCurrentScale);
This is the line where I am providing the filter.
string videoFilter = "System.Kind:=System.Kind#Video";
Short answer: .srt and other subtitle files are classified as video files since any app supporting playback might want access to srt files.
You can add an application search filter ext:<>.srt to remove srt files from your results.
Long Answer: The inevitable question is why not have another type for Kind:Subtitles or something? Why include them for with Kind:Video?
Well there is another pressure that goes on the Kind mappings beyond just "does this extension make sense as a video"? It all comes back to the SD card access on Windows Phone.
See for Windows 8 an modern app accessing the SD card had to declare a file launch experience for any file type they wanted to see on the SD card. For example that meant that a video app would need a file launch experience for mp4, avi, ect. However, on Windows Phone this wouldn't work because there was no way for an app to override the default system app for mp4 or avi (there is another story here for another day). So we needed another way to give apps access to mp4 files on the SD card.
The solution was that since the UI already said "Grant this app access to Videos and your SD card" then any app with both the video library capability and SD card access should have access to all files of Kind.Video on your SD card. Thus Kind.Video not only meant "Video files" but also "Files a video app would want access to".
With this slightly changed definition, it meant that any files the built in video player needed were suddenly included in the Kinds.Video mapping. Which is where .srt files come from in the mapping.
And as one of the people responsible for making the kind mapping decisions, I'd like to take this opportunity to apologize my mess and promise I'm not nearly as brain dead as you'd think looking at this design. Probably
I am currently working on a customized media player in C#, the main purpose of this thing is to let the user to play his own music files.
I already have a player of this kind (https://bitbucket.org/_Bruce/media-player), it works fine but only wave files are supported.
This limitation bothers me because mp3 is a tiny format (about disk space).
I have already tried and more or less succeeded in this task by using the FromUri method but there is a tricky problem: if the user name of the machine contains a space the string will be not accepted by the compiler, i have tried to resolve this with Uri.EscapeUriString but Visual Studio says that a Dos path must be with a root like C:\.
The code I am trying is below or Full code here
string[] SongsToRead = Directory.GetFiles(Environment.CurrentDirectory, "*.mp3");
song song;
protected override void Initialize()
{
var var1 = Uri.EscapeUriString(SongsToRead[0]);
Song = Song.FromUri("Test", new Uri(var1));
base.Initialize();
}
Am I on the wrong side?
Thanks!
Well now that you have something to work with-
I, honestly, despite all my time working in XNA, never even knew there was a Song.FromUri(...) - I've never had any use for it.
If you're going to use XNA's built in system, just use the regular Content.Load<Song>("mysong"); method - or try loading it as a SoundEffect using SoundEffect.FromStream(new System.IO.FileStream("MyFile.mp3", System.IO.FileMode.Open)); - which is intended for .wav sounds but should be compatible with other MS-approved audio files.
If you want to avoid that because you think the Content Pipeline is annoying or SoundEffect won't work well, you have to first realize the entire XNA audio setup is rather poor as well.
I would recommend using the FMod-Ex Sound System (API) if you want dynamic control and loading-from-file-without-content-pipline of your audio.
(It's a bit complicated to setup initially, but once you get it the .dll file in the right place and the C# wrapper imported, it's a wonderfully useful thing and comparitively easy to use)
If you really want to work with your current code, the only thing I notice:
var var1 = Uri.EscapeUriString(SongsToRead[0]);
Don't do that. That converts, for example, myfolder\myfile.mp3 to myfolder%5Cmyfile.mp3, it's used for HTTP stuff. Not good here.
I'm trying to use the DirectShot.Net wrapper from "http://directshownet.sourceforge.net/" to extract frames from a number of video files.
Whenever I run the DxScan sample app. I get a "No combination of intermediate filters could be found to make the connection." This happens for WMV files, MP4 files, AVI files. Any media I point at the sample app.
If I open any of the videos using the GSpot codec tool and ask it to render the graph, it does so without problem. So the machine is definitely capable of playing the content.
I'm on Win 7 64 bit. The same error is thrown targeting x64, x86 or Auto. Including running Visual Studio as an Administrator.
I've modified the sample code to try and find the correct pin containing the video media type as suggested by Romain R below.
I'm using:
IEnumPins epins;
capFilter.EnumPins(out epins);
IntPtr fetched = Marshal.AllocCoTaskMem(4);
IPin[] pins = new IPin[1];
while (epins.Next(1, pins, fetched) == 0)
{
PinInfo pinfo;
pins[0].QueryPinInfo(out pinfo);
IEnumMediaTypes mtypes;
pins[0].EnumMediaTypes(out mtypes);
AMMediaType[] types = new AMMediaType[1];
while(mtypes.Next(1, types, new IntPtr()) == 0){
var majorType = types[0].majorType;
if (majorType == MediaType.Video)
{
//This is never reached
}
}
}
For MP4 files, it's never hitting the commented line above. However for WMV files, the demo will now run correctly.
Presumably, this is because it isn't finding an appropriate MP4 file filter. Which is obscure as the content will play fine in windows media player.
Is this a likely cause?
DxScan sample is building a filter graph in an unreliable way, in particular is makes an assumption that the first pin it grabs from the source filter supplied for a media file is a video pin. It is not always the case. A better graph building approach should be working out fine. You might want to step through to find out at what line you have an error. Most likely, it is going to be connection of Sample Grabber Filter input pin.
UPD. Note that it might so happen that original filter has no input pins, it requires additional filters in between, so called parser/demultiplexer filters which convert streams into video frames and audio samples. DirectShow API offers Render* methods to assist in graph building in terms of suggesting required links of this chain and direct connection DxScan is doing might or might not work out.
That is, DxScan might be not the best sample to start from, MSDN samples/reference for native API are perhaps better for taking off the ground with DirectShow.
Your playground and primary research and API exploration tool should be GraphEdit from Windows SDK (GraphStudio, or GraphStudioNext as alternate improved options), not a DirectShow.NET wrapper library sample.
Which is obscure as the content will play fine in windows media player.
WMP does not use DirectShow for playback.
I am using the following code to open flash:
private Process flash = new Process();
flash.StartInfo.FileName = ("Flash.exe");
flash.Start();
The target machine has many version of flash like flash cs5,4,3. I want to open the newest version or let the user choose, how can I possibly do that?
Typically speaking, all other flash installations would be in different program folders, so you would just need to make sure you're running Flash.exe from the right folder. For instance, my current installation lies here: C:\Program Files (x86)\Adobe\Adobe Flash CS5\Flash.exe, but an alternate one could very well be in C:\Program Files (x86)\Adobe\Adobe Flash CS4\Flash.exe`.
An important thing to notice is that you can't assume the user installed flash CS* in its default directory! You should always query the Windows registry to find the list of installed products.
Also, another notice would be that you don't need parentheses around string literals. So you can just write:
string foo = "Hello!";
instead of
string foo = ("Hello!");
Edit 1:
Hey, I found a similar problem being treated in a forum thread here! I downloaded the code sample and ran it through a vb.net -> C# converter (like this one) and got it to work after a few minor syntax tweaks. Now it's able to output a list of the installed programs with their appropriate version numbers.
There will be a bunch of methods that get programs form e.g. certain users. All of these will then be placed in a common list, returned to the user. Now, this seems perfect, but there is just one flaw - no path is available... so far!
You can just query the UninstallString, and get a path to the uninstaller (which is IIRC in the same folder as Flash.exe). For instance, in GetUninstallKeyPrograms, after the
try
{
IsSystemComponent = Convert.ToInt32(CurrentSubKey.GetValue("SystemComponent", 0));
}
snippet, you can try to get the UninstallString value in order to obtain the path. Hope it helps!