In this recipe, we will see how to create a simple MP3 player with the Play, Pause, Stop, Next, and Previous buttons. Here, the focus will be on how to learn the interaction between UI and the Audio Source (Script) component within a script. Furthermore, we will see how to use the Event Trigger (Script) component to call all the functions in our script. These will actually implement the logic behind the MP3 player.
First, we can create a panel by right-clicking on the Hierarchy panel and then clicking on UI | Panel. Rename it to MP3Panel. We should also resize it so that we can see the entire panel on the screen. This is the panel that will contain all the buttons of our player.
Next, we need to create five buttons inside the panel. To do this, we can right-click on MP3Panel in the Hierarchy panel and then click on UI | Button. We can easily duplicate it four times by pressing Ctrl + D. Each time, place the button on the screen as shown in the following...