Silverlight MediaElement video issue - c#

Cant display the video in Silverlight.Which i saved in sql server and retrieve it from database as byte[] and subsequently convert it as Stream and put as SetSource of Media element.But cant display anything.
Plz help me.
Like this:
MediaElement SoundClip = new MediaElement();
SoundClip.SetSource(stream);
SoundClip.AutoPlay = false;
SoundClip.Width = 500;
SoundClip.Height = 500;
SoundClip.Stretch = Stretch.Fill;
this.LayoutRoot.Children.Add(SoundClip);
SoundClip.Play();
But does not work.
EDIT:
It is in wmv format.
I could not even play a wmv/wma file from local drive.Is there any issue with the PC i m using.It just runs the code but does play it.does not show any error.
Any suggestion?

What format is the media?
Can it be played directly as a WMV, WMA, MP3, or H.264 file?
Is the media file completely downloaded?
Monitor the HTTP traffic using Fiddler to see what's happening
Attach a MediaElement.MediaFailed event to the SoundClip to see the error (if any)

Related

I can't play UDP video stream whit LibVLCSharp

I am beginning to learn how to use the LibVLCSharp library. Right now I am trying to play a streaming video that comes to me in multicast UDP, 224.XX.XX.XX:PORT. The problem is that said video comes to me without format.
I get to reproduce it in cmd with:
vlc udp://#224.XX.XX.XX:PORT --demux=mp4v --rawvid-fps=12
This is mi code:
public void PlayURLFile(string file)
{
var media = new Media(_libVLC, "udp://#224.XX.XX.XX:XXXXX");
media.AddOption(":demux=mp4v");
media.AddOption(":rawvid-fps=12");
_mp.Play(media);
isPlaying = true;
}
When executing it does not show me any error.
The videoview I have to show the video shows me the black screen.
I understand that the problem may be that I am not entering AddOption correctly or that the options are different. But after fighting with the code and looking at documentation, I can't find an answer that is clarifying.
Can someone help me?
Greetings and thank you.
Give the following options in the LibVLC ctor instead.
new LibVLC("--demux=mp4v", "--rawvid-fps=12");

NAudio Loopback Record Crackle Sound Error

I'm recording sound via the WasapiLoopbackCapture and write it to an MP3-File via the NAudio.Lame lib:
LAMEPreset quality = LAMEPreset.ABR_320;
audiostream = new WasapiLoopbackCapture();
audiostream.DataAvailable += stream_DataAvailable;
audiostream.RecordingStopped += stream_RecordingStopped;
mp3writer = new LameMP3FileWriter(Environment.GetEnvironmentVariable("USERPROFILE") + #"\Music\record_temp.mp3",
audiostream.WaveFormat, quality);
audiostream.StartRecording();
When the user presses the stop-recording-button, I save the MP3 and stop the recording:
mp3writer.Flush();
audiostream.Dispose();
mp3writer.Dispose();
All works fine, except that the output file has some disturbing crackle noises in it. (See here for example). I think it might be the case, that my computer is a bit to slow to do the process of compressing and writing the audio data in realtime, so some of the values get lost, but that is just my guess
Edit: When recording to WAVE, the errors dont appear.
What may be the problem here and how could I possibly solve it / work around it?
start off by saving your audio to a WAV file. Does that have crackles in it? If so the crackles are coming from the soundcard. If not, they are coming from the encoding to MP3 code.

MediaElement web Video doesn't stop buffering

I m using MediaElement to play a web video. When I left the page I noticed in the Task Manager that my app was still using 10% of network and didn't drop till it finished downloading video.
I tried doing the following but no luck.
//open link;
mediaElement.Source = welcomeVideoURL;
//when I leave the page OnNavigatedFrom()
mediaElement.Stop();
mediaElement.ClearValue(MediaElement.SourceProperty);
mediaElement.Source = null;
Also tried to set the source to a dummy link but still no luck.
I thought that opening the Link as a Stream and use mediaElement.SetSource() could work but I haven't found anything on that...maybe I m not searching correct.
Thank you.
Found this MediaElementWithHttpClient in some other question in a comment made by #kiewic. I can manage the stream and download process and easily dispose it.
HttpRandomAccessStream videoStream = await HttpRandomAccessStream.CreateAsync(new Windows.Web.Http.HttpClient(), videoUrl);
mediaElement.SetSource(videoStream, videoStream.ContentType);

Splicer Libraries are not supporting the mp3 format

I'm a trying to create a simple application in C#.NET that can generate a video file from a stream of Images and an audio file.
I chooses the Splicer and its working perfectly fine with my part of code. However when I try to put an mp3 audio format it shows an ERROR:An invalid media type was specified.
I scanned the Splicer forum but didn't get anything useful.
Any kind of help is appreciated.
Here is a simple code:
using (ITimeline timeline = new DefaultTimeline())
{
IGroup audioGroup = timeline.AddAudioGroup();
ITrack rootTrack = audioGroup.AddTrack();
rootTrack.AddAudio("testinput.mp3");
using (
WindowsMediaRenderer renderer =
new WindowsMediaRenderer(timeline, "output.avi", WindowsMediaProfiles.LowQualityAudio))
{
renderer.Render();
}
}

Media player c# playing from network

I´m trying to play a file located on network at address:
string filePath = #"\\192.168.xx.xx\folder\folder2\Audio\audio.wav";
and trying to play it in MediaPlayer.MediaPlayer player like this:
m_player = new MediaPlayer();
m_player.Stop();
m_player.Open(new Uri(path));
m_player.Play();
It doesn't return any exception, but it also does not play the sound.
When I copy the file on a local disk and try to play it, it works fine.
Any ideas where the problem could be?
Doing some Google says, that you should try a relative Uri.
m_player = new MediaPlayer();
m_player.Stop();
m_player.Open(new Uri(path, UriKind.Relative));
m_player.Play();
Otherwise have a look at this example, which opens a stream and sets the stream to the MediaPlayer.
The SoundPlayer class can do this. It looks like all you have to do is set its Stream property to the stream, then call Play.

Categories

Resources