I create usercontrol name it Audio_Play..
and the code in Audio_Play.xaml.cs is :
private int _count = 8;
// MediaElement
private int _index = 0;
public AudioPlayer()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(AudioPlayer_Loaded);
}
void AudioPlayer_Loaded(object sender, RoutedEventArgs e)
{
for (int i = 0; i < _count; i++)
{
var element = new MediaElement();
element.Volume = 0.7d;
root.Children.Add(element);
}
}
private void Play(string address)
{
if (_index > _count - 1)
_index = 0;
var element = root.Children[_index] as MediaElement;
element.Source = new Uri(address, UriKind.Relative);
element.Stop();
element.Play();
_index++;
}
public void PlayDrop()
{
Play("/Skrip;component/Resources/over.mp3");
}
public void PlayEat()
{
Play("/Skrip;component/Resources/eat.mp3");
}
public void PlaySkin()
{
Play("/Skrip;component/Resources/skin.mp3");
}
public void PlayOver()
{
Play("/Skrip;component/Resources/over.mp3");
}
}
then i describe it in Main.xaml
behind Main.xaml.cs I call PlayDrop(), PlayEat(), PlaySkin(), PlayOver(), when some action on going. But it's not working.. how to fix it.?
and I create some action with usercontrol main.xaml, in this main.xaml.cs I create Boolean to give Enabled = false (the coding behind isnot running/Stop), and Enabled = true (the coding behind it is running)..=>> (Stop and Play the action in main.xaml).
In center action I call other usercontrol and name it soal.xaml
I stop main.xaml : main.Enabled = false, then call soal.xaml, => i doit with "if"
then when soal.xaml visibility is collapsed, main.xaml is start again. main.enabled = true. continuing the previous action. I can't coding it..
many thanks..