I will assume that you have installed the tools for working like Visual Studio 2012 ( or 2013 ) and that you’re on Windows 8 at least ( or 8.1 ) .
In this workshop we will learn to use a MediaElement in our Windows Phone application .
We will begin with setting up our XAML code , we will use two buttons for a Playing and Stoping , and a slider for the volume and of course a MediaElement :
Let’s move now to the C# code and get our MediaElement to run , we will need aDispatcherTimer : it’s a timer which is processed at a specified interval of time and at a specified priority. Also we will ned to configure our MediaElement depending on the MediaOpened or Stopped , it will be like this :
We will set up now the source of our sound and code the eventhandlers for the click on the two buttons :
We will be set up the code for the slider right now and control the volume with some C# code :
Run your project and you click run and the MediaElement will play the sound that you already used , you can use a local MP3 file also , you just need to set up the right path in the code .
No comments:
Post a Comment