Introduction
Xamarin is a platform to develop cross-platform and multi-platform apps (for example - Windows phone, Android, iOS). In Xamarin platform, the code sharing concept is used. In Xamarin Studio, Visual Studio is also available.
AVAudioPlayer
AVAudioPlayer class calls an audio player and provides playback of audio data from a file or memory.
Xamarin is a platform to develop cross-platform and multi-platform apps (for example - Windows phone, Android, iOS). In Xamarin platform, the code sharing concept is used. In Xamarin Studio, Visual Studio is also available.
AVAudioPlayer
AVAudioPlayer class calls an audio player and provides playback of audio data from a file or memory.
Using an AVAudioPlayer
- Play sounds of any duration.
- Play sounds from files or memory buffers.
- Loop sounds.
- Play multiple sounds simultaneously, one sound per audio player, with precise synchronization.
- Control relative playback level, stereo positioning, and playback rate for each sound you are playing.
- Seek to a particular point in a sound file, which supports such application features as fast forward and rewind.
- Obtain data you can use for playback-level metering.
Prerequisites
- Xamarin Studio.
- Xcode.
The steps given below are required to be followed in order to Control Volume Using AVAudioPlayer in Xamarin iOS, using Xamarin Studio.
Step 1
Go To Xamarin Studio.
Click New Solution—> select iOS—>select App--> Choose single View App. Afterwards, click Next.

Step 2
In this step, configure your app. Give the app name (Ex - sample) and organization identifier. Afterwards, click Next.

Step 3
In this step, give your project name (Ex: Sample) and solution name (Ex: Sample). Give the path of your project. Afterwards, click Create.

Step 4
Subsequently, go to the solution. In the solution, you will get all the files and sources in your project.
Step 1
Go To Xamarin Studio.
Click New Solution—> select iOS—>select App--> Choose single View App. Afterwards, click Next.

Step 2
In this step, configure your app. Give the app name (Ex - sample) and organization identifier. Afterwards, click Next.

Step 3
In this step, give your project name (Ex: Sample) and solution name (Ex: Sample). Give the path of your project. Afterwards, click Create.

Step 4
Subsequently, go to the solution. In the solution, you will get all the files and sources in your project.
Now, select Main.storyboard and double click to open Main.storyboard page.

Step 5
After opening the Main.storyboard, you can design this page as per your desire.

Step 6
In this step, design your app using Storyboard, Toolbox and Properties, and add the following three components.

Step 5
After opening the Main.storyboard, you can design this page as per your desire.

Step 6
In this step, design your app using Storyboard, Toolbox and Properties, and add the following three components.
- Slider (volumeControlSlider).
- Label (lblVolume).
- Button (btnPlay).

Step 7
In this step, add one folder and name it as Sounds.
Go to Solution—>Resource—>Right click—>Add—>New Folder.

Step 8
In this step, add a sound fiel from your Local system.
Go to Solution—>Resource-->Right click-->Add-->Add Files. Now, you can choose the required sound file. Click Open.
Next, choose "Copy the Files to the directory". Afterwards, click OK.

Step 9
In this step, go to the ViewController.cs page and write the code given below.
ViewController.cs




Manav PandyaPosted Jul 12, 2017, 12:14 AM
Nice one ................