Media Player with Audio Clip?

I want to make a simple Media Player app play mp3 file. I can play mp3 with Audio Clip on Unity? Or something else? Because when i compare the mp3 on Unity with an app on App Store, i see there is one small difference, seem App Store’ sounds better, good. Someone can tell me little of basic knowledge for Media Player App? Thank you.

First you need to Create an Audio source on unity and uncheck Play on Awake if you don’t want it to play when you start the game and then make a script for example, Example.cs

inside the Example.cs you need to make a public AudioSource, and public AudioClip

using UnityEngine;
        
using System.Collections;



public class Example : MonoBehaviour
{
       public AudioSource TestSource;
       public AudioClip TestClip;
       //When the game starts it will stop the audio just incase the audio is running
       void Awake(){
        TestSource.stop();
        }      
       //When the script is started it will Change the Clip of the audio source to testclip then play it.
       void Start(){
      //Change TestSource's clip to TestClip
        TestSource.clip = TestClip;
     // Play the Audio
       TestSource.play();
        }
}

you need to create an empty game object and attach that script to it.
Then you will see TestSource and TestClip variable,
Put the audio source you created on TestSource.
and The .mp3 file on TestClip then you are done :slight_smile:

1 Like

Thank for your help. But, the question here: the sound play on Audio Clip is the best?

1 Like

Yes for sure! I have used it in a lot of projects and it’s just working awesome and very easy to use!

1 Like

Thank pro, so, how about flac? Can you tell me “keyword” to play it on Unity App?