use of com.att.aro.core.fileio.impl.FileManagerImpl in project VideoOptimzer by attdevsupport.
the class LoadManifestDialog method loadManifest.
/**
* Copy a file, files or a folder of files into tracepath/downloads/ Will traverse folders within a folder
*/
protected void loadManifest(AnalysisFilter analysisfilter) {
if (aroView.getTracePath() != null) {
// Open filechooser
JFileChooser fileChooser = new JFileChooser(aroView.getTracePath());
fileChooser.setMultiSelectionEnabled(true);
fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("mpd, m3u8 or json", "mpd", "m3u8", "json"));
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setAcceptAllFileFilterUsed(false);
int result = fileChooser.showOpenDialog(this);
if (result == JFileChooser.APPROVE_OPTION) {
if (checkBoxCSI.isSelected() && analysisfilter != null) {
String folderNameForCSIStuff = aroView.getTracePath() + File.separator + "CSI";
String expectedManifestFileName = folderNameForCSIStuff + File.separator + fileChooser.getSelectedFile().getName();
File expectedManifestFile = new File(expectedManifestFileName);
try {
if (!fileChooser.getSelectedFile().getPath().equals(expectedManifestFileName) && !expectedManifestFile.exists()) {
IFileManager fileManager = new FileManagerImpl();
if (fileManager.directoryExistAndNotEmpty(expectedManifestFile.getParentFile().getPath())) {
if (folderExistsDialog() == JOptionPane.YES_OPTION) {
FileUtils.deleteDirectory(expectedManifestFile.getParentFile());
}
}
if (!Files.exists(expectedManifestFile.getParentFile().toPath())) {
Files.createDirectory(expectedManifestFile.getParentFile().toPath());
}
if (fileChooser.getSelectedFile().getParent().equals(aroView.getTracePath())) {
Files.move(fileChooser.getSelectedFile().toPath(), expectedManifestFile.toPath());
} else {
Files.copy(fileChooser.getSelectedFile().toPath(), expectedManifestFile.toPath());
}
}
} catch (IOException ioe) {
expectedManifestFileName = fileChooser.getSelectedFile().getPath();
}
analysisfilter.setCSI(true);
analysisfilter.setManifestFilePath(expectedManifestFileName);
((MainFrame) aroView).updateFilter(analysisfilter);
} else {
// save selected file/files inside downloads folder
fileChooser.getSelectedFile().getPath();
String downloadsPath = aroView.getTracePath() + Util.FILE_SEPARATOR + "downloads";
try {
File[] files = fileChooser.getSelectedFiles();
if (!files[0].toString().equals(downloadsPath)) {
// expand out of folder
if (fileChooser.getSelectedFile().isDirectory()) {
files = files[0].listFiles();
}
if (null == files) {
return;
}
for (File file : files) {
if (file.isFile()) {
FileCopyUtils.copy(file, new File(downloadsPath, file.getName()));
}
}
} else {
LOG.error("user error :Chose downloads folder, will ignore");
}
} catch (IOException e1) {
LOG.error("IOException :" + e1.getMessage());
}
// refresh analyzer
aroView.updateTracePath(new File(aroView.getTracePath()));
}
}
}
}
use of com.att.aro.core.fileio.impl.FileManagerImpl in project VideoOptimzer by attdevsupport.
the class AROVideoPlayer method refresh.
/**
* Refreshes the Video player display using the specified analysis data.
*
* @param analysisData
* The analysis data that is used to refresh the video.
* @throws IOException
*/
private void refresh() throws IOException {
aroAdvancedTab.setVideoPlayer(this);
// file:/Users/barrynelson/AROTraceAndroid/nt/video.mov
String mediaUrl = VideoUtil.getMediaUrl(traceFile);
if (traceFile == null || mediaUrl == null) {
setVideoNotAvailableImage(true);
return;
}
double videoStartTime = tdResult.getVideoStartTime();
if (videoStartTime < 0.00001) {
// checking if the video start time isn't available
videoStartTime = new FileManagerImpl().getCreatedTime(mediaUrl) * 1000;
}
MediaLocator mlr = new MediaLocator(mediaUrl);
try {
videoPlayer = Manager.createRealizedPlayer(mlr);
} catch (NoPlayerException noe) {
MessageDialogFactory.getInstance().showErrorDialog(new Window(new Frame()), ResourceBundleHelper.getMessageString("video.error.noplayerexception") + noe.getMessage());
return;
} catch (IOException ioe) {
MessageDialogFactory.getInstance().showErrorDialog(new Window(new Frame()), ResourceBundleHelper.getMessageString("video.error.ioexception") + ioe.getMessage());
} catch (CannotRealizeException cre) {
MessageDialogFactory.getInstance().showErrorDialog(new Window(new Frame()), ResourceBundleHelper.getMessageString("video.error.cannotrealizeexception") + cre.getMessage());
return;
}
this.videoOffset = videoStartTime > 0.0 ? videoStartTime - ((double) tdResult.getTraceDateTime().getTime() / 1000) : 0.0;
// Resetting the offset if the offset is longer than the video
if (Math.abs(videoOffset) >= videoPlayer.getDuration().getSeconds()) {
videoOffset = 0;
}
videoPlayer.setRate(PLAYBACK_RATE);
setVideoNotAvailableImage(false);
// This is to turn off plug-in settings on video info window, plugin tab
Control[] controls = videoPlayer.getControls();
for (int i = 0; i < controls.length; i++) {
String strControlName = controls[i].toString();
if (strControlName.contains("BasicJMD")) {
Component basicJMDComp = controls[i].getControlComponent();
if (basicJMDComp.getParent() != null) {
basicJMDComp.getParent().setVisible(false);
}
basicJMDComp.setVisible(false);
}
}
controlComponent = videoPlayer.getControlPanelComponent();
if (controlComponent != null) {
controlComponent.setVisible(true);
aroVideoPanel.add(controlComponent, BorderLayout.SOUTH);
}
visualComponent = videoPlayer.getVisualComponent();
if (visualComponent != null) {
aroVideoPanel.add(visualComponent, BorderLayout.CENTER);
visualComponent.setVisible(true);
}
videoPlayer.addControllerListener(new ControllerListener() {
@Override
public void controllerUpdate(ControllerEvent evt) {
if (evt instanceof StartEvent || evt instanceof MediaTimeSetEvent) {
if ((evt instanceof StartEvent) && showInfoMsg && tdResult.isExVideoTimeFileNotFound()) {
if (!syncVideoClicked) {
MessageDialogFactory.showMessageDialog(AROVideoPlayer.this, "The Analyzer loaded an external video. The video may not be in Sync with the traces.", "Information", 1);
showInfoMsg = false;
} else {
showInfoMsg = false;
}
}
VideoSyncThread syncThread = new VideoSyncThread(AROVideoPlayer.this, aroAdvancedTab, videoOffset);
new Thread(syncThread).start();
}
}
});
setVisible(true);
if (!tdResult.isNativeVideo()) {
jButton.setVisible(true);
}
aroAdvancedTab.setGraphPanelClicked(false);
Double startTime = 0.0;
AnalysisFilter filter = ((MainFrame) aroView).getController().getTheModel().getAnalyzerResult().getFilter();
if (null != filter) {
startTime = filter.getTimeRange().getBeginTime();
}
setMediaTime(startTime);
}
Aggregations