Sign in to follow this  

Unity Custom Mobile Audio Player for Unity3d

Recommended Posts

Hello code veterans, Im currently working on a project that requires the use of an Audio player in unity3d. Since Im doing this audio player from scratch I have the Play, Pause, Stop and the seekbar working perfectly. (seekbar took an entire day breaking my head off on trying to write a formula to calculate the time and seekbar width accurately).


However since this is on mobile, the user has to be able to move the bar circle to the desired time the user wants to listen to. Kind of like youtube where you want to skip to your favorite part of a video by moving the circle. Ive been stuck on this for around 1 1/4 day's and Ive been dead stuck, only making tiny progress. Heres my Bar circle code as well as a bit of my play pause code.



#pragma strict

import PlayPause;
var script : PlayPause;
var sensisitivity : float = 300.0f;

var timeCaptured : float = 0.0f;
var totalTimey : float = 0.0f;

var minX : float = 114.5f;
var maxX : float = 0.0f;

function LateUpdate () {
		timeCaptured = script.capturedTime;
		totalTimey =; //using a varible = the length of the audioclip (which is read only)
		totalTimey -=; //when the audio starts, the time subtracts the length. which makes it count down. = timeCaptured;
		var h : float = sensisitivity * Input.GetAxis("Mouse X");
		gameObject.guiTexture.pixelInset.x += h;
		script.capturedTime = ( * script.gameObject.guiTexture.pixelInset.x)/;

and a bit from the playpause

private var paused = false;

public var capturedTime : float = 0;
private var totalTime : float = 0;
private var clickChecker : float = 0;
private var seekbarTime : float = 0;

function Start () { = clip; //insert the clip to the audio source
	play.guiTexture.enabled = true; //play gui
	pause.guiTexture.enabled = false; //stop gui
	seekbar.guiTexture.pixelInset.width = seekbarLimit; //for visual purposes

function LateUpdate () {
	totalTime =; //equal the varible to the length of the audioclip (which is read only)
	totalTime -=; //when the audio starts, the time subtracts the length. which makes it count down.
	audioTime.guiText.text = totalTime.ToString(); //just for displaying text
	seekbarTime =;
	if(paused == false){
		capturedTime =; //for saving audio time
	else if(paused){
		capturedTime = capturedTime; //when audio is paused, catch the time
	seekbar.guiTexture.pixelInset.width = ( * seekbarLimit)/; //calculating the time for the seekbar ACCURATLY
	seekbar.guiTexture.pixelInset.width = Mathf.Clamp(seekbar.guiTexture.pixelInset.width, 0.0f, seekbarLimit); //clamp the seekbar so it doesnt go over its boundarys

Please excuse my lousy and messy coding but can anyone suggest or think of a solution that best helps what I'm currently trying to do please and thank you :)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Announcements

  • Forum Statistics

    • Total Topics
    • Total Posts
  • Similar Content

    • By sveta_itseez3D
      itSeez3D, a leading developer of mobile 3d scanning software, announced today a new SDK for its automatic 3D avatar generation technology, Avatar SDK for Unity. The Avatar SDK for Unity is a robust plug-n-play toolset which enables developers and creatives to integrate realistic user-generated 3D avatars into their Unity-based applications. SDK users can allow players to create their own avatars in the application or integrate the SDK into their own production processes for character design and animation.
      “Virtual avatars have recently become increasingly popular, especially in sports games and social VR apps. With the advance of VR and AR, the demand to get humans into the digital world is only increasing”, said Victor Erukhimov, itSeez3D CEO. “Our new Avatar SDK for Unity makes it super-easy to bring the avatar technology into any Unity-based game or VR/AR experience. With the Avatar SDK for Unity now every developer can bring face scanning technology into their games and allow players to create their own personalized in-game avatars, making the gameplay much more exciting and immersive.”
      Key features of the Avatar SDK for Unity:
      Automatic generation of a color 3D face model from a single selfie photo in 5-10 seconds (!). Works best with selfies, but can be used with any portrait photo.
      Shape and texture of the head model are unique for each person, synthesized with a deep learning algorithm crafted by computer vision experts
      Head models support runtime blendshape facial animations (45 different expressions)
      Generated 3D heads include eyes, mouth, and teeth
      Algorithms synthesize 3D meshes in mid-poly resolution, ~12k vertices, and ~24k triangles
      Six predefined hairstyles with hair-recoloring feature (many more available on request)
      Avatar generation API can be used in design-time and in run-time, which means you can allow users to create their own avatars in your game
      Cloud version is cross-platform, and offline version currently works on PCs with 64-bit Windows (support for more platforms is coming soon)
      Well-documented samples showcasing the functionality.
      The Avatar SDK for Unity is offered in two modes - “Cloud” and “Offline”. The “Cloud” version is available at and the “Offline” version is available by request at
      About itSeez3D
      At itSeez3D, we are working on the computer vision technology that turns mobile devices into powerful 3D scanners. itSeez3D has developed the world's first mobile 3D scanning application that allows to create high-resolution photorealistic 3D models of people's' faces, bodies and objects. The application is available for iOS and Windows OS mobile devices powered with 3D cameras. In 2016 the company introduced Avatar SDK that creates a realistic 3D model of a face from a single selfie photo. To learn more about itSeez3D scanning software and 3D avatar creation technology, please visit and

      View full story
  • Popular Now