DAV extension file length - c#

I have written my own .DAV file player in C# for individual use. There is too much code to attach if I would have to explain what it exactly is. How can I get the .DAV file length in time to my player?
There is no meta-data like time-length for dav files in windows, and I can't find anything in Google. I will add that I can not count it on when file was created and as last modified. I was thinking about making a counter on file start in the player in seconds, but it is not what I mean. I would like to show how long the file is in time, and place it beside my progress bar like every player should look like.
My player is using VLC libraries.

Related

How to store txt file (reading/writing) and build for Android

I'm making a game about questions shared between people, and I want to add natively some questions to the game. In the way I made this game, I need to store a text file in Unity, that contains on each line information about these questions. I need to read and write on that txt file at runtime.
So I basically made a file questions.txt in the Resources folder, and it's actually fine in the Unity Editor: I can write and read as I want.
However, when I tried on my android device, the txt file couldn't be found.
I read that it's because the Resources folder isn't built on android.
Then, I'm lost. I've read about TextAsset, but it's read-only. I Couldn't find a way to make this work with Application.dataPath and Application.persistentDataPath, because the file is actually not created with some script.
That's why I'm asking for some help now. I'm a bit lost and I just want some hints on how to implement that.
Thanks for taking some time to read and help. :)
I figured out how to, in my case at least.
Made a script that contains a public TextAsset. I assigned my questions.txt to that TextAsset through the inspector.
TextAsset is read-only. But here is the tip: I completly copied the content of that file to another that I created in Application.persistentDataPath, which allows reading and writing.
Then, if I want to add native questions the game, all I need to do is copy the lines I need from the TextAsset I can modify before building.
Thanks to #blackapps for the little hint. Solved!

Why is my .wav file not playing?

I want to create an application where i can play a .wav file after the input matches a certain number.
Now I've only come up across threads on how to check if the input is only numbers etc. but i couldn't find any solution yet for my problem.
Here's some code I'm currently using:
if(fortwenty_Tb.Text.Equals("420"))
{
player.Play();
}
The application works, but the sound isn't playing.
I've already checked if the .wav file was faulty, but it isn't since it does work after i tried playing it with a button controller.
First of all, you have to use debugger and breakpoints to ensure that Play() is called. Then you have to check volume of player, volume of your application in windows mixer, and, additionaly, file integrity and codec.

can't figure out what is wrong with Song.FromUri

I want to load a song with the Song.FromUri() method, it works with some files, doesn't work with others. All i could find out is that if i try to play a song from a downloaded album, it won't play, but if i try to play one randomly google'd and downloaded, it plays well. I tried to place the "wrong" file to the Content folder and load it with Content.Load<Song>("filename") method, it perfectly plays, but i can't do it that way since it would be a player application, and the user has to choose own files. Any advice?
No, there is no exception, it simply does nothing. Anyway, i made another way.

Keeping the last X minutes of a recording video

I'm developing an app which requires me to record a lot of video data but I don't need to store them all.
What I need to do is to keep just the last X minutes of the recorded stream.
This means that I need a way to remove the oldest sample everytime that I need to store a new one.
So I started working with this article: http://msdn.microsoft.com/library/windowsphone/develop/hh394041%28v=vs.105%29.aspx
The first idea that I had was to just call the StopVideoRecording() and then the StartVideoRecording() using a timer each X minutes.
Now, at first this made sense but it won't work.
The problem is that doing this way will delete the previous data each X minutes.
This means that, if we record 12 minutes and we need to keep the last 5, following this idea we'll delete the first 5 and then the second five, leaving just the last 2 minutes and this is not what I was looking for.
I moved then my attention to the VideoSink class because of the OnSample method.
This seems pretty simple, we intercept every sample and we store it in a fixed size byte array (the size depends on the needed length and the sample's size).
When the buffer is full we just shift everything on the left before adding the new sample.
The problem is that a test video of just 1 minute generated something like 2GB of samples and this makes this way really hard to manage.
I know that those samples are uncompressed, but wouldn't be hard, for a smartphone, to get a sample, compress it, shift a big array, insert the sample and write the array to a file and do it on EVERY sample received?
Yeah, I'm talking about writing the array to a file because we need to persist this video somehow. It may happen that the battery stops working, and having it just in RAM will let us loose everything that we recorded!
The last idea that came to mind was to use a combo of VideoSink and FileSink.
While the FileSink does the compression magic (I even decompiled this class to understand what it does but there's no code inside!), we use the VideoSink's OnSample method to manually remove the unneeded data from the mp4 file used by the FileSink.
This one sounds quite hard because I don't know if I can write to the file with both FileSink and VideoSink without concurrency issues, and I've not found a good c# library to help me working with the mp4 files without having to deal with its structure.
The only library that I found is this one http://basemedia.codeplex.com/ but it totally lacks documentation (each link in the documentation page gives a 404 error).
I'm starting to think that this is something that can't be done, but I'd like to see if there's someone here which can point me to the right direction.
EDIT:
Just to be clear, I used the "recording" word and not the "recorded" one beacuse I'm talking about trimming the video while it's still recording!
This is not about editing it once it has been saved, but something more like removing stuff from the stream while I'm writing it to disk.
I cannot provide a code to you but just an idea. Because you have requirements:
I need to do is to keep just the last X minutes of the recorded stream.
Target platform is windows phone 8
I want to add some modifications to your first idea:
Write each minute of video stream in the separate file
Also you need to leave +1 video file more then a number of minutes. For instance if you need 5 minutes you should always keep 6 files because last file may be not full.
By use DirectShow you will able to join this files into one. Be ready to use C++ (As alternative to this you can use some service or make own back-end for this)

C# Windows Application Programming: index all files from folder and play at random with my default application?

I'm trying to index every music file in a folder and play them at random (without repeating) with the default application on my system. For example:
ogg - itunes
mp3 - WMP
mp4 - quicktime
Are there tutorials that will help me with this? Thanks!
Well, once you have a list of files, if you want to come up with a (pseudo)-random permutation of them, what you want is a shuffle algorithm, like Knuth-Fisher-Yates.
If you have a single filename and you want to open it with the default application, you can probably use:
System.Diagnostics.Process.Start(mp3FileName);
See also the MSDN documentation on Process.Start.
This will behave equivalently to just double-clicking on the files in whatever order the shuffle comes up with. Depending on your media player, that may be good enough. However, unless you somehow know how long each media file is, you won't know how long to wait before starting the next one, and I don't think there's any way to wait for the music player to finish playing the media file without having special-case code specific to each player.
You may be able to use the Verb property of the ProcessStartInfo object to select "Enqueue" or something similar, which may do exactly what you want. Again, MSDN has some additional information on ProcessStartInfo.Verb that may be helpful to you.

Categories