Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Problem with looping sounds
7 replies. Latest Post by shamrat231 on December 3, 2008.
(0)
abeaulieu
Member
660 points
112 Posts
05-26-2007 10:55 PM |
I would like to continuously loop a background sound. I am using the following method, but there is a slight skip (no sound) between each loop of the sound....
In my xaml, I have:
<MediaElement x:Name="soundX" Source="sounds/XXX.wma"></MediaElement>
In my code behind I have:
soundX.MediaEnded += new EventHandler(soundX_MediaEnded); soundX.Play();
void soundX_MediaEnded(object sender, EventArgs e) { soundX.Stop(); soundX.Play(); }
Is there another way to loop the sound without a skip?
Dave Relyea
Participant
1084 points
249 Posts
05-29-2007 4:45 PM |
That's the technique. One thing you can try is to to play the same sound twice, but start the second sound with an offset, e.g. if it is a 1s sound you are looping, start the same sound .5s later, also in a loop.
Also, some MP3s end with incomplete frames, so that may increase the silence between the repetitions.
GearWorld
840 points
1,101 Posts
11-17-2008 6:54 AM |
Cool a workaround. But what is needed is a fix :)
Priyamjm
234 points
32 Posts
11-17-2008 11:06 AM |
1 void soundX_MediaEnded(object sender, EventArgs e) 2 { 3 soundX.Stop(); 4 soundX.Position = new TimeSpan(0); 5 soundX.Play(); 6 } 7
11-17-2008 7:14 PM |
The prolem is not the looping it's a glitch in reading the stream. It looks like the first time a sound is played its nice and then the second time it looks like the sound plays half its content or sometimes if the sound is short enough it'll not play at all the second time.
bartczer...
Contributor
4078 points
723 Posts
11-17-2008 7:55 PM |
I saw people had good results using Encoder and using WMAs vs mp3s.
djprod
334 points
65 Posts
12-03-2008 3:38 PM |
see my reply to a similar question here:-
http://silverlight.net/forums/p/3599/141811.aspx#141811
Regars, Marc.
shamrat231
4649 points
591 Posts
12-03-2008 11:15 PM |
Here is a post by Jonathan about sound looping
Have a look
http://silverlight.net/forums/p/53437/138609.aspx
and if the post was helpful then please 'Mark as Answer' - many thanks
Sharker Khaleed MahmudSoftware Developer(MCP,MCTS,MCPD[web])
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.