GP-2858 - fixes to update the PR with theming concepts

This commit is contained in:
dragonmacher 2022-11-21 10:38:26 -05:00
parent 0398f47f05
commit 1f70c3ffdc
3 changed files with 12 additions and 20 deletions

View File

@ -4,9 +4,7 @@
icon.content.handler.archive.dt = closedBookBlue.png
icon.content.handler.program = program_obj.png
icon.data.type.aiff = audio-volume-medium.png
icon.data.type.au = audio-volume-medium.png
icon.data.type.wave = audio-volume-medium.png
icon.data.type.audio.player = audio-volume-medium.png
[Dark Defaults]

View File

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -19,38 +19,32 @@ import java.awt.event.MouseEvent;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.*;
import javax.sound.sampled.LineEvent.Type;
import javax.sound.sampled.LineListener;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.ImageIcon;
import javax.swing.Icon;
import generic.theme.GIcon;
import ghidra.util.Msg;
import resources.ResourceManager;
public class AudioPlayer implements Playable, LineListener {
private static final ImageIcon AUDIO_ICON =
ResourceManager.loadImage("images/audio-volume-medium.png");
private static final Icon AUDIO_ICON = new GIcon("icon.data.type.audio.player");
private byte[] bytes;
public AudioPlayer(byte[] bytes) {
this.bytes = bytes;
}
@Override
public ImageIcon getImageIcon() {
public Icon getImageIcon() {
return AUDIO_ICON;
}
@Override
public void clicked(MouseEvent event) {
try (AudioInputStream stream = AudioSystem.getAudioInputStream(new ByteArrayInputStream(bytes))) {
try (AudioInputStream stream =
AudioSystem.getAudioInputStream(new ByteArrayInputStream(bytes))) {
Clip clip = AudioSystem.getClip();
clip.addLineListener(this);
clip.open(stream);
@ -72,6 +66,6 @@ public class AudioPlayer implements Playable, LineListener {
if (event.getSource() instanceof Clip clip) {
clip.removeLineListener(this);
clip.close();
}
}
}
}