Skip to content

Commit

Permalink
#1723 adds audio spectrum view with clickable seek during replay and …
Browse files Browse the repository at this point in the history
…reorganizes channel view panel with additional css styling.
  • Loading branch information
Dennis Sheirer committed Dec 26, 2023
1 parent d0f4030 commit 6145b09
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 246 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public AudioPlaybackControlView()
public void changed(ObservableValue<? extends MediaPlayer.Status> observable, MediaPlayer.Status oldValue,
MediaPlayer.Status newValue)
{
System.out.println("Media Player Status From: " + oldValue + " To: " + newValue);
if(newValue != null)
{
switch(newValue)
Expand Down Expand Up @@ -115,16 +114,9 @@ public void changed(ObservableValue<? extends MediaPlayer.Status> observable, Me
}
break;
case STALLED:
//TODO: something??
System.out.println("Playback is STALLED");
break;
case HALTED:
//TODO: something??
System.out.println("Playback is HALTED");
break;
case DISPOSED:
//TODO: something??
System.out.println("Playback is DISPOSED");
System.out.println("Playback is " + newValue);
break;
}
}
Expand Down Expand Up @@ -153,13 +145,8 @@ public ObjectProperty<MediaPlayer> mediaPlayerProperty()
}

/**
* Clears the media player for this view.
* Playback toggle buttons group (play, stop, and pause)
*/
public void clearMediaPlayer()
{
mMediaPlayer.set(null);
}

private ToggleGroup getPlaybackGroup()
{
if(mPlaybackGroup == null)
Expand All @@ -172,17 +159,14 @@ private ToggleGroup getPlaybackGroup()
{
if(getPlayButton().equals(selectedToggle))
{
System.out.println("PLAY button clicked");
mediaPlayer.play();
}
else if(getPauseButton().equals(selectedToggle))
{
System.out.println("PAUSE button clicked");
mediaPlayer.pause();
}
else if(getStopButton().equals(selectedToggle))
{
System.out.println("STOP button clicked");
mediaPlayer.stop();
}
}
Expand Down Expand Up @@ -331,9 +315,7 @@ private class EndOfMediaRunnable implements Runnable
@Override
public void run()
{
System.out.println("End of media triggered - auto-clicking STOP button");
getStopButton().setSelected(true);
}
}

}
162 changes: 0 additions & 162 deletions src/main/java/io/github/dsheirer/audio/playback/AudioSpectrumView.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package io.github.dsheirer.audio.playbackfx;

import io.github.dsheirer.audio.call.Call;
import io.github.dsheirer.audio.playback.AudioSpectrumView;
import io.github.dsheirer.identifier.Identifier;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
Expand All @@ -46,26 +45,20 @@ public class AudioPlaybackChannelController
private StringProperty mToAlias = new SimpleStringProperty();
private ObjectProperty<PlaybackMode> mPlaybackMode = new SimpleObjectProperty<>();
private ObjectProperty<Identifier<?>> mLockedIdentifier = new SimpleObjectProperty<>();
private AudioSpectrumView mAudioSpectrumView;
private Call mCall;
private boolean mAutoTerminate;
private double mBalance;

/**
* Constructs an instance.
* @param name to display for the channel.
* @param balance to effect audio playback balance where -1.0 is full left and 1.0 is full right.
*/
public AudioPlaybackChannelController(String name)
public AudioPlaybackChannelController(String name, double balance)
{
nameProperty().set(name);
playbackModeProperty().set(PlaybackMode.AUTO);
}

/**
* Registers a listener to receive audio spectrum results while the media is playing.
* @param view to register
*/
public void setAudioSpectrumListener(AudioSpectrumView view)
{
mAudioSpectrumView = view;
mBalance = balance;
}

/**
Expand All @@ -82,23 +75,26 @@ public void play(Call call, boolean autoTerminate)
mCall = call;
mAutoTerminate = autoTerminate;
updateCallMetadata(mCall);
setPlaybackMode(PlaybackMode.MANUAL);
setPlaybackMode(PlaybackMode.REPLAY);

if(mMediaPlayer.get() != null)
{
mMediaPlayer.get().stop();
mMediaPlayer.get().setAudioSpectrumListener(null);
}

if(mCall.getFile() != null)
{
mMediaPlayer.set(new MediaPlayer(new Media("file://" + mCall.getFile())));
mMediaPlayer.get().setAudioSpectrumListener(mAudioSpectrumView);
mMediaPlayer.get().balanceProperty().set(mBalance);
}
else
{
mMediaPlayer.set(null);
}
}
else if(call == null)
{
mCall = call;
mCall = null;
mAutoTerminate = autoTerminate;
updateCallMetadata(mCall);
clearMediaPlayer();
Expand All @@ -115,11 +111,6 @@ private void clearMediaPlayer()
mMediaPlayer.get().stop();
mMediaPlayer.set(null);
}

if(mAudioSpectrumView != null)
{
mAudioSpectrumView.reset();
}
}

/**
Expand Down
Loading

0 comments on commit 6145b09

Please sign in to comment.