21
21
package com.bdaum.zoom.ui.internal;
23
import java.applet.Applet;
24
import java.applet.AudioClip;
25
23
import java.io.ByteArrayInputStream;
26
24
import java.io.File;
27
25
import java.io.IOException;
49
47
import javax.sound.sampled.AudioSystem;
50
48
import javax.sound.sampled.Clip;
51
49
import javax.sound.sampled.DataLine;
50
import javax.sound.sampled.LineEvent;
51
import javax.sound.sampled.LineListener;
52
52
import javax.sound.sampled.LineUnavailableException;
53
53
import javax.sound.sampled.UnsupportedAudioFileException;
454
456
isResetImage, isResetStatus, isResetExif, isResetIptc,
455
457
isResetGps, isResetFaceData, processSidecars, rawimport, this,
456
458
dnguncompressed, dnglinear, deriverelations, autoDerive,
457
applyXmp, dngfolder.trim(), alarmonprompt,
458
alarmonfinish, inBackground, makerNotes, archiveRecipes,
459
applyXmp, dngfolder.trim(), alarmonprompt, alarmonfinish,
460
inBackground, makerNotes, archiveRecipes,
459
461
meta.getJpegQuality(), showImported,
460
462
getEnabledRelationDetectors(), obtainAutoRules());
782
775
final IDbManager dbManager = activator.getDbManager();
783
776
if (dbManager.getFile() != null) {
777
Meta meta = dbManager.getMeta(false);
779
meta.setLastSessionEnd(new Date());
780
dbManager.safeTransaction(null, meta);
784
782
if (mode != CatalogListener.TASKBAR) {
785
783
Set<String> postponed = Core.getCore()
786
784
.getDbFactory().getLireService()
787
785
.postponeIndexing();
788
786
waitOnCancel(Constants.OPERATIONJOBFAMILY);
789
787
waitOnCancel(Constants.FILETRANSFER);
790
if (!postponed.isEmpty()) {
791
Meta meta = dbManager.getMeta(true);
793
meta.setPostponed(postponed);
794
dbManager.safeTransaction(null, meta);
788
if (!postponed.isEmpty() && meta != null) {
789
meta.setPostponed(postponed);
790
dbManager.safeTransaction(null, meta);
798
793
repairCat = false;
810
805
activator.deleteTrashCan();
811
806
if (!BatchActivator.isFastExit()
812
807
&& dbManager.isEmbedded()) {
813
Meta meta = dbManager.getMeta(true);
814
808
boolean hasBackups = meta == null
815
809
|| meta.getBackupLocation() != null
816
810
&& meta.getBackupLocation().length() > 0;
942
play(Core.getCore().getVolumeManager().findVoiceFile(asset));
935
URI voiceURI = Core.getCore().getVolumeManager()
936
.findVoiceFile(asset);
938
playSoundfile(voiceURI.toURL(), null);
939
} catch (MalformedURLException e) {
972
971
if (peerService.transferRemoteFile(
973
972
new NullProgressMonitor(), assetOrigin,
974
973
voiceInfo, tempFile)) {
975
play(tempFile.toURI());
974
playSoundfile(tempFile.toURI().toURL(), null);
978
977
} catch (URISyntaxException e) {
997
private void play(URI uri) {
1000
AudioClip sound = Applet.newAudioClip(uri.toURL());
1002
setAudioClip(sound);
1003
} catch (MalformedURLException e) {
1009
996
public void stopAudio() {
1010
AudioClip sound = getAudioClip();
1011
if (sound != null) {
1017
1001
public IImageViewer[] getImageViewers() {
1091
1075
URL url = FileLocator.findFileURL(getBundle(),
1092
1076
"/sound/" + sound + ".wav", true); //$NON-NLS-1$ //$NON-NLS-2$
1093
1077
if (url != null)
1078
playSoundfile(url, null);
1095
1079
} catch (IOException e) {
1100
public void playSoundfile(URL clipURL) {
1102
AudioInputStream ais = AudioSystem.getAudioInputStream(clipURL);
1084
public long getSoundfileLengthInMicroseconds(URL clipURL) {
1086
final AudioInputStream ais = AudioSystem
1087
.getAudioInputStream(clipURL);
1088
Clip clip = (Clip) AudioSystem.getLine(new DataLine.Info(
1089
Clip.class, ais.getFormat()));
1090
long musec = clip.getMicrosecondLength();
1093
} catch (Exception e) {
1098
public void playSoundfile(URL clipURL, final Runnable onStop) {
1101
final AudioInputStream ais = AudioSystem
1102
.getAudioInputStream(clipURL);
1103
clip = (Clip) AudioSystem.getLine(new DataLine.Info(Clip.class, ais
1104
Clip clip = (Clip) AudioSystem.getLine(new DataLine.Info(
1105
Clip.class, ais.getFormat()));
1109
} catch (IllegalStateException e) {
1110
// line already open
1107
} catch (IllegalStateException e) {
1108
// line already open
1110
clip.addLineListener(new LineListener() {
1111
public void update(LineEvent event) {
1112
if (event.getType() == LineEvent.Type.STOP) {
1119
} catch (IOException e) {
1113
while (clip.isRunning())
1121
1126
} catch (IOException e) {
1123
1128
} catch (LineUnavailableException e) {