This is the first audio sample. It demonstrates the basic workflow of loading an external audio. You can also see the differences in pausing, replaying and seeking the audio element.
It seems that Flash has some bugs when trying to play at a specific position. You may experience that the progress bar will drop to zero when you click on the second half of the bar. However, it works perfectly in my Flash IDE and I don’t have any idea how to solve it.
Comparison
Flash implementation: 1 hour
Silverlight implementation: 1 hour (Implemented First)
What’s the difference?
- Sound [AS3] vs MediaElement [C#]
Source codes
Audio Player [Flash 9, AS3] (324.6 KiB, 1,995 hits)
Audio Player [Silverlight 2, C#] (25.3 KiB, 2,347 hits)
Flash
Silverlight
Sound [AS3] vs MediaElement [C#]
Here is a simple demonstration in manipulating an external audio.
// AS3
var _sound:Sound;
var _soundChannel:SoundChannel;
var _position:Number;
var request : URLRequest = new URLRequest(URL);
_sound = new Sound();
_sound.addEventListener(Event.COMPLETE, on_complete);
_sound.load(request);
// finish loading, play the audio
private function on_complete(e : Event):void{
_soundChannel = _sound.play();
}
// pause the audio
_position = _soundChannel.position;
_soundChannel.stop();
// replay the audio
_soundChannel = _sound.play_position;
In Silverlight, Video and Audio shared the same Class MediaElement. Don’t forget to add the object to the stage. Otherwise, you can never load the audio. Personally, I like the Audio Object in Silverlight since the API seems simpler to use.
// C#
MediaElement _mediaElement = new MediaElement();
_mediaElement.Source = new Uri(URL, UriKind.Absolute);
_mediaElement.MediaOpened += new RoutedEventHandler(_mediaElement_MediaOpened);
LayoutRoot.Children.Add(_mediaElement);
// finish loading, play the audio
void _mediaElement_MediaOpened(object sender, RoutedEventArgs e)
{
_mediaElement.Play();
}
// pause the audio
_mediaElement.Pause();
// replay the audio
_mediaElement.Play();

October 30th, 2008 at 1:04 pm
bug with silverlight: download, play, drag the progress bar to certain place(what ever, let’s say 1 minute), it won’t play any more, no matter you clcik pause/play.
October 30th, 2008 at 1:59 pm
really? I just can’t reproduce the bug..
October 31st, 2008 at 10:53 am
strange er? I could reproduce it every time
October 31st, 2008 at 11:35 am
did you try IE8 beta?
August 15th, 2009 at 10:59 pm
Have a case in court to know to visit at, thanks!
November 20th, 2009 at 10:12 am
Thanks, this is a useful comparason. Developing a media player in Silverlight is very much easier, in fact it’s a joy. The end product is more versatile and gives better performance and a superior user experience — especially HD video with Smooth Streaming.
January 1st, 2010 at 1:06 pm
silverlight much better and the streaming is faster than flash
August 29th, 2010 at 8:45 am
The siverlight version sounds cleaner
October 27th, 2010 at 6:12 pm
http://www.Tvhind.com
February 26th, 2011 at 2:21 pm
Did you see silverlight audio player anywhere? There are no silverlight players in the internet
August 5th, 2011 at 11:04 am
Yeah, there are plenty
November 9th, 2011 at 4:45 am
4…
“BanXie” is the ground type of board type shoes. It comes from the skateboard people wear shoes, so also called skateboarding shoes. BanXie compared with general shoes, different place is: it is almost a flat bottom, easy to let feet are able to comp…
November 9th, 2011 at 12:58 pm
3…
OAKLEY glasses glasses products on the concept of subversion is that it is the glasses comfortable, practical, artistic fusion of one. Whether it is product design or choice of materials, have been a series of advanced scientific experiments and testin…