Tag Archives: SilverlightAddict

Buy Guduchi Without Prescription

Roger from SilverlightAddict.com asked me for more information about how I manage the sound effects in the Silverlight version of Legend of the Greasepole Buy Guduchi Without Prescription, . Buy cheap Guduchi no rx, I have a Canvas element in my scene called MusicCanvasRoot.  It contains a number of MediaElement children equal to the maximum number of simultaneous sounds that the game will play. This helper method allows my sound routines to find an unused MediaElement, buy Guduchi from canada, Where to buy Guduchi, and returns null if the maximum number of sounds is currently playing:





private static List<MediaElement> MediaElements = null;


private static int MaxSimultaneousSounds = 14;


private static MediaElement GetFreeMediaElement()


{


if (MediaElements == null)


{


MediaElements = new List<MediaElement>();


for (int i = 0; i < MaxSimultaneousSounds; i++)


{


MediaElement me = new MediaElement();


MediaElements.Add(me);


Page.Instance.MusicCanvasRoot.Children.Add(me);


}


}


foreach (MediaElement me in MediaElements)


{


if (me.Tag == null) return me;


}


return null;


}




When a sound is playing in a MediaElement, Guduchi in australia, Guduchi trusted pharmacy reviews, I set the Tag on the MediaElement to indicate whether or not the sound is looping.  Here's the internal method that handles requests that come in to play a sound:




private void DoPlay(int volume, int pan, bool looping)


{


MediaElement mediaElement = GetFreeMediaElement();


if (mediaElement == null) return;


mediaElement.MediaEnded += me_MediaEnded;


mediaElement.Volume = Page.Instance.IsMuted . 0d : 1d;


if (looping) mediaElement.Tag = "PLAYLOOP"; else mediaElement.Tag = "PLAYONCE";


Buy Guduchi Without Prescription, // ...

// Assign a Uri to mediaElement.Source

//

// My sounds are stored as MP3 files stored as Resources in an

// Assembly that is downloaded after the app starts.

// ...



// TODO: Set Volume and Pan in Silverlight.


// This allows me to implement IsPlaying for a particular sound effect


MyMediaElements.Add(mediaElement);


mediaElement.Position = TimeSpan.Zero;


mediaElement.Play();


}



And here's the Event Handler for the MediaEnded event, which managing stopping sounds, or looping them when they complete:



void me_MediaEnded(object sender, RoutedEventArgs e)


{


MediaElement me = sender as MediaElement;


if (((string)me.Tag) == "PLAYLOOP")


{


me.Position = TimeSpan.Zero;


me.Play();


return;


}


else


{


ReleaseMediaElement(me);


}


}



private void ReleaseMediaElement(MediaElement me)


{


me.MediaEnded -= me_MediaEnded;


me.Stop();


me.Tag = null; // free it up for use by another sound effect.


MyMediaElements.Remove(me);


}


The string-based Tags are a throwback to Silverlight 2 Beta 1, where the Tag exhibited some strange behavior that seems to be resolved in Beta 2.

Hope that helps. Let me know if you have any questions or want a full drop of the sound code.

Similar posts: Buy Kytril Without Prescription. Buy Imodium from canada.
Trackbacks from: Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Buy Guduchi Without Prescription. Guduchi prescriptions.

Posted in Development, Microsoft | Tagged , , , | 5 Comments