I'm looking at libvlcnet 0.4.0.0 "SimplePlayer" example from http://sourceforge.net/p/libvlcnet/wiki/Home/ and I want to ask if is it possible to to open new file and play it from predefined position without needing to play the start of the movie? I use something like this:
LibVlcInterop.libvlc_media_player_play(descriptor);
LibVlcInterop.libvlc_media_player_pause(descriptor);
LibVlcInterop.libvlc_media_player_set_position(descriptor, (float)0.8);
int res = LibVlcInterop.libvlc_media_player_play(descriptor);
When trying to play new file user can notice small fraction of the beginning of the movie.
How can I position player to particular area after I load new file without showing small portion of the beginning of movie?
I don't know about that particular library, but you can do this generally by passing "media options" before you play the media. To do this use the LibVLC API function libvlc_media_add_option.
If you can do this in that library, then you can specify a start time and/or an end time - but it has to be specified as seconds rather than as a percentage position.
The options you would pass to the API function would be:
:start-time=30
:stop-time=60.5
You can actually pass fractional seconds as shown in the stop-time example.
When I do this, I do not notice any flash of content showing the beginning of the movie but I suppose that still might happen on some platforms or with some types of media.
Related
I have a very simple app that creates a text file (after a button click) and sends it to a certain email address(after another button click). I want to add the ability to change the name of the text file that is created based on how many times the file was sent, or i.e. how many times the app successfully ran till the end. Currently, the name of the text file is fixed.
My idea:
I am thinking of adding a check on start-up of the app to see if another text file exists, lets called it Counter.txt. This will contain the number of times the 'send' button was clicked. If the file doesn't exist, then it will create it and append the number 0. Every time the 'send' button is clicked, it will open Counter.txt and increment that number. Also on a 'send' click, it will email the main textfile that I want to send and adjust the name by appending the number from Counter.txt to it.
I am not sure if this is the best or most efficient method, so would appreciate other suggestions to achieve this. Thanks.
Why not use SharedPreferences to store the number of times the app was launched and increment the value on the onCreate() method of your main Activity?
Then when the mail is sent, the file is renamed based on the SharedPreferences value.
I think it's better than changing the file name each time the app is started.
Here is a good Stack Overflow post on how to use SharedPreferences, you should check it out! There is also another post on how to rename a file here.
Hope this helps!
If you have a relatively small collection of key-values that you'd like to save, you should use the SharedPreferences APIs. ~ Android Developer Documentation
// Create your shared preferences
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
// Write to shared preferences
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putInt("yourkey", yourvalue); // You could store the counter right here
editor.commit();
// Read from shared preferences
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
int defaultValue = 0;
int lastcounter = sharedPref.getInt("yourkey", defaultValue);
Simarly to this question I want to find the location of the last item in a PDF document and add content at that place, more specifically I would like to add an electronic signature at a position where one would normally put a regular handwritten signature on letters.
In the question above the user is making the PDF file but I am importing an existing PDF file that can have any structure as such. Therefore, as far as I can see, I can not use the same method as I do not know if the last object made was a paragraph or some other object.
I found the following function and property on the PdfWriter class that bode well but can not find any documentation that explains the output I get when I run the programme:
PdfWriter w = _document.GetWriter();
long currentPos = w.GetCurrentPos();
long pos = w.Position;
When I run this the output I get is something like the number 84178. What unit is that? Can I use this number to calculate how much vertical space there is left on the page and if it is too small then add a page and have the signature on the next page?
So, long story short: I'm writing a POS program, and I have a receipt printer connected and the Windows Forms printing API works great with it, much easier than I expected.
However, searching through the API, it seems that the easiest (or perhaps only) way to programmatically print something is to use the Graphics object inside the PrintPageEventArgs object in the printer's event handling method.
Every overloaded parameter list for the Graphics.DrawXXX() method requires some kind of coordinate pair to use as a reference point for where to start drawing the object passed to it.
So my question is, let's say I want to print some string value, and then an Image. Doing it the other way around (first the Image, then the string) would be easy because the reference point to start drawing the string would be (0, Image.Size.Height). However, since a string does not have a "size" associated with it, what is the best way to go about telling the printer where to start drawing an image after a string has been printed?
Let me know if this is confusing or needs additional clarification.
I already build a solution for speech recognition from a wav file and break the words apart for lipsync application, what i need from speech recognition system is words + its timing withing the wav file. I need to get the timing of every word even character (letter) any type of timing will work it can't be done under "SpeechRecognizedEventArgs" event I tried "SpeechDetected" it return the start of detection , might work. I tried:
static void recognizer_SpeechDetected(object sender, SpeechDetectedEventArgs e)
{
Console.WriteLine(" Speech detected at AudioPosition = {0}", e.AudioPosition);
// TimeSpan interval = new TimeSpan(0, 0, 01);
// Console.WriteLine(interval.ToString())
}
I'm getting just some millisec before audio starts.
AudioPosition inside recoginzed event giving me the full time of the wav file .
What I'm think about I need something like a loop "foreach" to get timing if there isn't other way to get it with recognized event with words, or 2nd option is to play wav file like 2 sec and recognize a word or half then complete. Its all about getting some kind of timing .
Maybe all of those are complex ideas cause i don't know C#.
If your not looking to code the whole thing yourself, this company offers a product which does what you describe:
http://www.freakngenius.com/
If you do want to make your own solution, then one idea might be to look at the volume of the audio at different points. A drop in the volume would probably indicate a break between words.
i have written a custom mediastreamsource, that can play media from growing source files (mpeg transport streams).
Once it reaches the end of its mediastream, it reads the new duration from the mediafile and continues to deliver samples. The MediaElement plays continously.
Unfortunately i haven´t found a way to update the MediaElement.NaturalDuration property. Hence i cannot seek into the “reloaded” area, because ME doesn´t know about it and sets my position change to its NaturalDuration value.
I tried to call ReportOpenMediaCompleted after getting the new stream length. Then Naturalduration get´s updated, but i cannot play anymore.
Is there any other way to deal with it ?
Sometime life can be so easy :-)
I solved it giving MediaElement a "fantasy" duration value when initializing my MediaStreamSource :
protected override void OpenMediaAsync()
{
...
mediaSourceAttributes[MediaSourceAttributesKeys.Duration] = TimeSpan.FromHours(10).Ticks.ToString(CultureInfo.InvariantCulture);
this.ReportOpenMediaCompleted(mediaSourceAttributes, mediaStreamDescriptions);
}
The only thing left to do was to update my slider control with the "real" duration.
Now it works like a charm ...
Tilo