WP7 MediaElement download problems - silverlight

I'm running into problems on the WP7 with MediaElement downloading a 128kbps mp3 stream from a web service for a music player app that i'm working on. The file downloads correctly when the wp7 is on a wifi connection, but downloading sometimes stops when off of wifi. The problem is that i'm not getting any errors or exceptions when the downloading fails and the MediaElement state is "playing". MediaElement runs right past the downloaded portion of the stream and acts like it is playing, but there is nothing to play since the download stopped. I can somewhat replicate this issue based upon my location and using the 3g instead of wifi, so i believe it is due to a low connection. I don't believe any code needs to be shown in this instance, but i try to post something. I want to know if I have any control over this? Are there any other events I could use to detect when the download has failed? Is there another way I could download a mp3 stream that is more reliable and play it? Is there another player/component I should try?
Thanks in advance

You could always use MediaStreamSource to try to handle the download and implement streaming, to some extent. It is a more "painful" way of doing this since you will have to work with an extra media layer, but it pays off by improving playback stability.
Here is a starter example by Tim Heuer. Take a look specifically at how he takes advantage of a custom implementation of MediaStreamSource. Here is a more complex sample.
If streaming is not a requirement, you could download the file (and store it in the Isolated Storage) and then play from there.

Related

Playing a .mp4 file while writing it

This is a very simple task that I had such a hard time trying to do. My goal is pretty simple: send an mp4 file from my server to my client, and while its buffering and downloading I want to already play it. That means that I need to play a video.mp4 file while writing it, and I need it to display on some platform that I can control - like wxPython or WPF-Ironpython. Naturally, no such platform will let me play an open file for writing.
I have tried to implement and HTTP server (although totally unnecessary for my case, as I am writing an application-based Server-Client app) that would accept Range request, and when I run the server and load the URL on Chrome, it all works perfect and I can seek and buffering is great, but when I load it from WPF MediaElement it fails to play the video for some point (I cant really tell why as there is no documentation for this, any API, tutorials etc). I am really desperate.
I even thought about playing a video from a buffer and then just changing the buffer's content, but it doesn't seem like this possibility exists.
I am really stuck at this and I would love to get some suggestions. Please note that I am not a professional in this so I would appreciate if you could explain this to me in simple terms.
Thanks!
Not possible. MP4 is not the correct container for your application. You must use something like HLS/dash/fragmented MP4.

Is it possible with Codename One to record microphone input and play it back simultaneously?

I am using Codename One to record the microphone input and play it back to the connected earphones.
First of all if I record audio from mic to a file, and play it back when the recording is over, it works as expected. That's why based on this 2014 question I implemented 2 periodic tasks (timer and timertask), as long as 2 files : one for recording, one for playing. I set the periodic tasks period to values between 100 ms and some seconds, but the result was awful on the Android device. Indeed there were random gaps, it was not smooth at all, nor understandable.
I assume the overhead of writing to a file every period is too high and consequently is causing that behaviour. So using proper high-level Codename One methods does not seem the way to go.
Then in the same question from 2014, the requester is suggesting to create an inputstream from the recording Media and use it as input for the playing Media. However the method MediaManager.createMediaRecorderStream() does not seem to be available anymore. I tried to use the file used to record audio as InputStream for the playing Media through fs.openInputStream(recFilepath) but it did not output any sound nor error on the device.
So my question is whether or not I can achieve my goal with bare Codename One or do I have to use the native interface ? Moreover Shai (in the 2014 above mentioned question) wrote that the second approach with MediaManager.createMediaRecorderStream() might work on some platforms : is the android platform among these, or only iOS platform was aimed at ?
Any help appreciated and sorry for not posting code since I cleared it as soon as an attempt did not appear to work. So I really messed up with my code which now is not doing anything I targetted initially.
Cheers,
As far as I recall Android back in the day didn't support input stream for media and later only allowed capturing input directly as uncompressed WAV which makes full duplex usage impractical. This might have changed since as I recall they did some overhaul of their media libraries.
I'm not sure if this is exposed in our higher level code. Besides using native interfaces you can also help us improve Codename One by forking and hacking it e.g. this is the relevant code in the Android project:
https://github.com/codenameone/CodenameOne/blob/master/Ports/Android/src/com/codename1/impl/android/AndroidImplementation.java#L2804-L2858
This is a contribution guide to Codename One, it covers running in the simulator but that's a good start: https://www.codenameone.com/blog/how-to-use-the-codename-one-sources.html
You can test your changes on an Android device with instructions here: https://www.codenameone.com/blog/debug-a-codename-one-app-on-an-android-device.html

How to Check / Fix Broken Background Transfers - WP7

I am developing an application which provides video download feature using Background Transfer.
Some times it says download is completed but on loading it in MediaLauncher it says can't play this file immediately or after playing it for partial period. it is my understanding that file is broken.
is there any solution to verify after downloading that file while server do not providing any hashing technique (digital signatures) so that i can check after download if the file is good to play or not and moreover if there is any fixing technique.
I haven't checked but I think server provides partial download (pause / resume).
Thanks

Which is the best way to encode batch videos on server side?

I am making a general question since I am a developer and I have no advance experience on video elaboration. I have to preparare a web application with the purpose to allow video files upload on our company server and then video elaboration by server, on user command. The purpose of the web application is to allow to the user to make some elaboration on video depending on user action launch from the web app:
(server has to ) convert video in different format(mp4, flv...)
extact keyframes from video and saves them in jpeg format
possibility to extract audio from video
automatic control of quality audio & video (black frames,silences detection)
change scene detection and keyframe extraction
.....
This what's my bosses wanted from the web based application (with the server support obviously), and I understand only the first 3 points of this list, the rest for me was arabic....
My question is: Which is the best and fastest server side application for this works, that can support multiple batch video conversions, from command line (comand line for php-soap-socket interaction or something else..)?
Is suitable Adobe Media Server for batch video conversion?
Which are adobe products that can be used for this purpose?
Note: I have experience with Indesign Server scripting programing (sending xml with php and soap call...), and I am looking to something similiar for video elaboration.
I will appreciate any answers.
THANKS ALL
I suggest you start with the open source project FFmpeg. You can call the program from the command line and via a series of arguments specify the desired output types, thumbnails, etc.
As an aside, when you start looking around at Video related projects (MediaShare for example) you will find they are all using FFmpeg for their video processing.
as Nathan suggested, FFMPEG is the first choice. Also you can check MEncoder
Just to elaborate:
1) (server has to ) convert video in different format(mp4, flv...)
both FFMPEG and mencoder do this well
2) extact keyframes from video and saves them in jpeg format
as I know it's impossible using command-line interface of FFMPEG, not sure about mencoder. However they can save all frames as separate images
3) possibility to extract audio from video
both FFMPEG and mencoder do this well
4) automatic control of quality audio & video (black frames,silences detection)
you need to code this, using FFMPEG libraries or mencoder
5) change scene detection and keyframe extraction
it's not clear what your boss imposes here
I tried lot of videos converting in server side using advance Xuggler API libraries.
Xuggler is a free open-source library for Java developers which can be used to uncompress,
manipulate, and compress recorded or live video in real time. Xuggler uses the very
powerful FFmpeg media handling libraries under the hood, essentially playing the role of a
java wrapper around them. It is the easy way to uncompress, modify, and re-compress any
media file (or stream) from Java.
WebLinks : 1) http://www.xuggle.com/ -official website
2) http://www.javacodegeeks.com/2011/02/introduction-xuggler-video-
manipulation.html - example

Silverlight: How to Synchronize Audio Files Perfectly?

I'm trying to synchronize 5 audio files (mp3) each representing a musical instruments. I'm using MediaElements.
I'm starting all the MediaElements at the same time and it works perfectly until I try to pause/play these audio files. When I start them after the pause, they become unsynchronized.
Using a timer, I tried to check when they become unsynchronized, and tried to synchronize them again by giving them the same position... but this didn't work.
Any idea on how to synchronize audio files perfectly.
Regards.
Thanks for your help.
The closest you can get to syncing multiple media files is to use a custom MediaStreamSource. By making a media stream source, you feed to the MediaElement the samples and sample times. This allows for perfect control over synchronization. There is an example of MediaStreamSource and MP3 here. You will have to modify it to make it stay in sync.

Resources