Open uw Silverlight-project in je editor . Kopen van 2
Klik met de rechtermuisknop op uw project van het tabblad Projecten en klik op ' Existing Item toevoegen . " 3
Klik op de audio -bestand dat u wilt invoegen en klik op' openen '. < br > 4
klik met de rechtermuisknop op het bestand dat werd geïmporteerd , en klik op ' Eigenschappen'. 5
Stel de Build - actie -instelling op " Resource , " sluit het venster Eigenschappen . < br > 6
Voeg de volgende code tussen de en < /Grid > tags van de page.xaml bestand gekoppeld aan het project met behulp van de Silverlight- editor om een MediaElement verklaren. Vervang de Bron bestandsnaam , die in dit geval is " Boom.mp3 . " < Button Klik = " Button_Click_Music " Canvas.Left = " 10 " Canvas.Top = " 10 " width = " 80 " height = " 30 " Content = " Play Music " > < /Button > < MediaElement x : Name = " geluidsbestand " Bron = " Boom.mp3 " autoPlay = " False " > < /MediaElement > < /MediaElement > Telefoonkaarten < /Canvas > 7 Voeg de volgende code toe aan uw project code in de locatie die u wilt de MediaElement te verschijnen : using System ; gebruik System.Collections.Generic ; behulp van System . Linq ; gebruik System.Net ; gebruik System.Windows ; gebruik System.Windows.Controls ; behulp System.Windows.Documents ; gebruik System.Windows.Input ; gebruik System.Windows.Media ; gebruik System.Windows.Media.Animation ; behulp System . Windows.Shapes ; namespace Tip22 { public partial class Pagina : UserControl { openbare Pagina ( ) < br { InitializeComponent ( ) op ; } > private void stopAll ( ) op { SoundFile.Stop ( ) ; } private void Button_Click_Sound ( objecten afzender , RoutedEventArgs e ) { stopAll ( ) ; geluidsbestand . Play ( ) ; } 8 } } Klik op " Project " aan de bovenkant van de editor , klik op " Run project "om uw project te testen .
< Button Klik = " Button_Click_Music " Canvas.Left = " 10 " Canvas.Top = " 10 " width = " 80 " height = " 30 " Content = " Play Music " > < /Button > < MediaElement x : Name = " geluidsbestand " Bron = " Boom.mp3 " autoPlay = " False " > < /MediaElement > < /MediaElement > Telefoonkaarten < /Canvas > 7 Voeg de volgende code toe aan uw project code in de locatie die u wilt de MediaElement te verschijnen : using System ; gebruik System.Collections.Generic ; behulp van System . Linq ; gebruik System.Net ; gebruik System.Windows ; gebruik System.Windows.Controls ; behulp System.Windows.Documents ; gebruik System.Windows.Input ; gebruik System.Windows.Media ; gebruik System.Windows.Media.Animation ; behulp System . Windows.Shapes ; namespace Tip22 { public partial class Pagina : UserControl { openbare Pagina ( ) < br { InitializeComponent ( ) op ; } > private void stopAll ( ) op { SoundFile.Stop ( ) ; } private void Button_Click_Sound ( objecten afzender , RoutedEventArgs e ) { stopAll ( ) ; geluidsbestand . Play ( ) ; } 8 } } Klik op " Project " aan de bovenkant van de editor , klik op " Run project "om uw project te testen .
< Button Klik = " Button_Click_Music " Canvas.Left = " 10 " Canvas.Top = " 10 " width = " 80 " height = " 30 " Content = " Play Music " > < /Button >
< MediaElement x : Name = " geluidsbestand " Bron = " Boom.mp3 " autoPlay = " False " > < /MediaElement >
< /MediaElement > Telefoonkaarten
< /Canvas > 7
Voeg de volgende code toe aan uw project code in de locatie die u wilt de MediaElement te verschijnen :
using System ;
gebruik System.Collections.Generic ;
behulp van System . Linq ;
gebruik System.Net ;
gebruik System.Windows ;
gebruik System.Windows.Controls ;
behulp System.Windows.Documents ;
gebruik System.Windows.Input ;
gebruik System.Windows.Media ;
gebruik System.Windows.Media.Animation ;
behulp System . Windows.Shapes ; namespace
Tip22
{
public partial class Pagina : UserControl
openbare Pagina ( ) < br
InitializeComponent ( ) op ;
} >
private void stopAll ( ) op
SoundFile.Stop ( ) ; }
private void Button_Click_Sound ( objecten afzender , RoutedEventArgs e )
stopAll ( ) ;
geluidsbestand . Play ( ) ; }
8
}
} Klik op " Project " aan de bovenkant van de editor , klik op " Run project "om uw project te testen .