Add item to context menu to stop recording in RecordingsTab
This commit is contained in:
parent
45e569e08a
commit
fa745e9acc
|
@ -19,6 +19,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -107,6 +108,8 @@ public class LocalRecorder implements Recorder {
|
|||
stopRecordingProcess(model);
|
||||
}
|
||||
LOG.info("Model {} removed", model);
|
||||
} else {
|
||||
throw new NoSuchElementException("Model " + model.getName() + " ["+model.getUrl()+"] not found in list of recorded models");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.iheartradio.m3u8.PlaylistException;
|
|||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.HttpClient;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.Recording;
|
||||
import ctbrec.Recording.STATUS;
|
||||
import ctbrec.recorder.Recorder;
|
||||
|
@ -228,10 +229,25 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
|||
openInPlayer.setOnAction((e) -> {
|
||||
play(recording);
|
||||
});
|
||||
if(recording.getStatus() == STATUS.FINISHED) {
|
||||
if(recording.getStatus() == STATUS.FINISHED || Config.getInstance().getSettings().localRecording) {
|
||||
contextMenu.getItems().add(openInPlayer);
|
||||
}
|
||||
|
||||
MenuItem stopRecording = new MenuItem("Stop recording");
|
||||
stopRecording.setOnAction((e) -> {
|
||||
Model m = new Model();
|
||||
m.setName(recording.getModelName());
|
||||
m.setUrl(CtbrecApplication.BASE_URI + '/' + recording.getModelName() + '/');
|
||||
try {
|
||||
recorder.stopRecording(m);
|
||||
} catch (Exception e1) {
|
||||
showErrorDialog("Stop recording", "Couldn't stop recording of model " + m.getName(), e1);
|
||||
}
|
||||
});
|
||||
if(recording.getStatus() == STATUS.RECORDING) {
|
||||
contextMenu.getItems().add(stopRecording);
|
||||
}
|
||||
|
||||
MenuItem deleteRecording = new MenuItem("Delete");
|
||||
deleteRecording.setOnAction((e) -> {
|
||||
delete(recording);
|
||||
|
|
Loading…
Reference in New Issue