How can I get media element source (mp3 file) duration in windows phone 8 without playing the file.
Thanks,
There are at least 2 ways of doing this I can think of at the moment, however I´d recommend you to do it in this way:
first is to read it directly from file's MusicProperties by using GetMusicPropertiesAsync():
You might need to adapt the code a little bit, tell me if there´s something else you do need.
Related
Ok, the title tells what I need. I just wonder that is there any way to get DTS-audio output in mp4 (mkv) video files using MediaElement? It's looks like that Microsoft doesn't want to support DTS (still...yet...forever) so I'm trying to find other solution to solve this problem. For example some code project / lib or any other way that my app can convert / get audio track to ac3 , or any other solution? Oh, and wishing that solution works with Universal Windows Apps.
Is there a way to trim a mp3 file?
I did some research and every search was leading me to NAudio.
However NAudio doesn't support WP8.1. Actually I don't think it support any version of windows phone.
Is there any other way to trim a mp3 file? MP3s are made of frames and ID3 tags.
Is there a helper that could read mp3 frames and then copy them into a new file?
An MP3 file is a collection of MPEG frames that you can manipulate fairly easily. If you read the NAudio source code (specifically the Mp3Frame class) you'll find a fairly good set of C# code for reading the individual frames. From there you can index the frames, figure out their positions in time and copy out only the ones you're interested in to the output file.
It may be a bit more complex than that, but have a look at Mark's code in and around the Mp3Frame class for some more information on how it works.
Oh, and don't forget to credit him if you use his code.
Is it possible to capture video and audio in Silverlight5 and save it as movie in any video format?
Silverlight 5 can automatically detect video and audio capture devices, which you can open operations on using the System.Windows.Media.CaptureDeviceConfiguration class and associated classes.
http://chris.59north.com/post/Audio-recording-and-encoding-in-Silverlight.aspx has info on how to use those classes to save the audio to a Stream (as well as compressing it), which you can then save to disk.
http://www.dotnetfunda.com/articles/article1751-how-to-access-a-video-and-snap-a-picture-from-webcam-in-silverlight.aspx has similar info on how to access video and save images from webcams on to disk using Silverlight.
Pro Silverlight 5 in C# (excerpt on Google Books) has more information on how to do this.
I have been doing quite a lot of searching and I have yet to find any samples of anyone actually saving video. The best I have been able to come up with is saving a sequence of images. That doesn't really sound like a good solution
I'm trying to write a Silverlight application that reads a media file from a database (most likely a .mpeg or .mpg) and play it on the fly using either a Silverlight MediaPlayer or ExpressionMediaPlayer. When I try using Expression Media Player it plays .wmv and .mp4 files but NOT .mpeg or .mpg file extensions. Is this even possible? If so, HOW?!
I tried going a different route originally where I wrote a Service to Encode the file using a LiveJob and then play it on the ExpressionMediaPlayer from the port using mms://localhost:8080 but I couldn't figure out how to use that to Play/Pause the video. It just ran through once and stopped. Any suggestions on that?
I'm using Expression Encoder 3 & Silverlight 4 by the way.
i think you're out of luck, check out this page from msdn.
You are going to have to re-encode the file if you want it to play in Silverlight.
I'm doing a sample which will run mp3 files which are selected by the user. I
want to calculate the playing time of the file (e.g. 00:05:32). How can I calculate the playing time?
You could use TagLib Sharp
It exposes TagLib.AudioProperties.Duration
For Alvas.Audio library see code below
using (Mp3Reader mr = new Mp3Reader(File.OpenRead("len.mp3")))
{
int durationMS = mr.GetDurationInMS();
TimeSpan durationTS = TimeSpan.FromMilliseconds(durationMS);
}
You suggest in the tag that you're doing this in C#. This question deals with it:
Finding MP3 length in C#
And there's some code for reading the MP3 header and extracting relevant information (like the length) here:
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=79
I believe the Windows Media API (or windows mixer api or something, I can't recall the exact name) has a way to open and read sound files like mp3 and maybe get the time from it too. As an added bonus, by using that API you can open any audio format that will work in say Windows Media Player, so you're not limited to just mp3's.