Class BaseAudioTrack

    • Field Detail

      • accurateDuration

        protected final java.util.concurrent.atomic.AtomicLong accurateDuration
    • Constructor Detail

      • BaseAudioTrack

        public BaseAudioTrack​(AudioTrackInfo trackInfo)
        Parameters:
        trackInfo - Track info
    • Method Detail

      • assignExecutor

        public void assignExecutor​(AudioTrackExecutor executor,
                                   boolean applyPrimordialState)
        Specified by:
        assignExecutor in interface InternalAudioTrack
        Parameters:
        executor - Executor to assign to the track
        applyPrimordialState - True if the state previously applied to this track should be copied to new executor.
      • stop

        public void stop()
        Description copied from interface: AudioTrack
        Stop the track if it is currently playing
        Specified by:
        stop in interface AudioTrack
      • getIdentifier

        public java.lang.String getIdentifier()
        Specified by:
        getIdentifier in interface AudioTrack
        Returns:
        The identifier of the track
      • isSeekable

        public boolean isSeekable()
        Specified by:
        isSeekable in interface AudioTrack
        Returns:
        True if the track is seekable.
      • getPosition

        public long getPosition()
        Specified by:
        getPosition in interface AudioTrack
        Returns:
        Get the current position of the track in milliseconds
      • setPosition

        public void setPosition​(long position)
        Description copied from interface: AudioTrack
        Seek to the specified position.
        Specified by:
        setPosition in interface AudioTrack
        Parameters:
        position - New position of the track in milliseconds
      • setMarker

        public void setMarker​(TrackMarker marker)
        Description copied from interface: AudioTrack
        Set the track position marker. This will clear all existing markers.
        Specified by:
        setMarker in interface AudioTrack
        Parameters:
        marker - Track position marker to place
      • addMarker

        public void addMarker​(TrackMarker marker)
        Description copied from interface: AudioTrack
        Adds a marker to the track. Markers can be used to execute code when the track reaches a certain position.
        Specified by:
        addMarker in interface AudioTrack
        Parameters:
        marker - The marker to add.
      • removeMarker

        public void removeMarker​(TrackMarker marker)
        Description copied from interface: AudioTrack
        Removes a marker from the track.
        Specified by:
        removeMarker in interface AudioTrack
        Parameters:
        marker - The marker to remove.
      • provide

        public AudioFrame provide​(long timeout,
                                  java.util.concurrent.TimeUnit unit)
                           throws java.util.concurrent.TimeoutException,
                                  java.lang.InterruptedException
        Specified by:
        provide in interface AudioFrameProvider
        Parameters:
        timeout - Specifies the maximum time to wait for data. Pass 0 for non-blocking mode.
        unit - Specifies the time unit of the maximum wait time.
        Returns:
        Provided frame. In case wait time is above zero, null indicates that no data is not available at the current moment, otherwise null means the end of the track.
        Throws:
        java.util.concurrent.TimeoutException - When wait time is above zero, but no track info is found in that time.
        java.lang.InterruptedException - When interrupted externally (or for seek/stop).
      • provide

        public boolean provide​(MutableAudioFrame targetFrame)
        Specified by:
        provide in interface AudioFrameProvider
        Parameters:
        targetFrame - Frame to update with the details and data of the provided frame.
        Returns:
        true if a frame was provided.
      • provide

        public boolean provide​(MutableAudioFrame targetFrame,
                               long timeout,
                               java.util.concurrent.TimeUnit unit)
                        throws java.util.concurrent.TimeoutException,
                               java.lang.InterruptedException
        Specified by:
        provide in interface AudioFrameProvider
        Parameters:
        targetFrame - Frame to update with the details and data of the provided frame.
        timeout - Timeout.
        unit - Time unit for the timeout value.
        Returns:
        true if a frame was provided.
        Throws:
        java.util.concurrent.TimeoutException - If no frame became available within the timeout.
        java.lang.InterruptedException - When interrupted externally (or for seek/stop).
      • getDuration

        public long getDuration()
        Specified by:
        getDuration in interface AudioTrack
        Returns:
        Duration of the track in milliseconds
      • makeClone

        public AudioTrack makeClone()
        Specified by:
        makeClone in interface AudioTrack
        Returns:
        Clone of this track which does not share the execution state of this track
      • getSourceManager

        public AudioSourceManager getSourceManager()
        Specified by:
        getSourceManager in interface AudioTrack
        Returns:
        The source manager which created this track. Null if not created by a source manager directly.
      • createLocalExecutor

        public AudioTrackExecutor createLocalExecutor​(AudioPlayerManager playerManager)
        Specified by:
        createLocalExecutor in interface InternalAudioTrack
        Parameters:
        playerManager - The player manager which is executing this track
        Returns:
        A custom local executor for this track. Unless this track requires a special executor, this should return null as the default one will be used in that case.
      • setUserData

        public void setUserData​(java.lang.Object userData)
        Description copied from interface: AudioTrack
        Attach an object with this track which can later be retrieved with AudioTrack.getUserData(). Useful for retrieving application-specific object from the track in callbacks.
        Specified by:
        setUserData in interface AudioTrack
        Parameters:
        userData - Object to store.
      • getUserData

        public <T> T getUserData​(java.lang.Class<T> klass)
        Specified by:
        getUserData in interface AudioTrack
        Parameters:
        klass - The expected class of the user data (or a superclass of it).
        Returns:
        Object previously stored with AudioTrack.setUserData(Object) if it is of the specified type. If it is set, but with a different type, null is returned.
      • makeShallowClone

        protected AudioTrack makeShallowClone()