Skip to content

Commit

Permalink
MediaConvert: Added error messages
Browse files Browse the repository at this point in the history
... when converted file cannot be writen to destination

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

Fixes #12334.
  • Loading branch information
thezealousfool authored and pulkomandy committed Mar 12, 2017
1 parent ad7783e commit fdd3fd9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/apps/mediaconverter/MediaConverterApp.cpp
Expand Up @@ -204,6 +204,18 @@ MediaConverterApp::_CreateOutputFile(BDirectory directory,

name.Append(outputFormat->file_extension);

BEntry directoryEntry;
directory.GetEntry(&directoryEntry);
if (!directoryEntry.Exists()) {
BAlert* alert = new BAlert(B_TRANSLATE("Error"),
B_TRANSLATE("Selected directory not found. "
"Defaulting to /boot/home"),
B_TRANSLATE("OK"));
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
directory.SetTo("/boot/home");
}

BEntry inEntry(ref);
BEntry outEntry;

Expand Down Expand Up @@ -318,6 +330,11 @@ MediaConverterApp::_RunConvert()


} else {
srcIndex++;
BString error(
B_TRANSLATE("Error converting '%filename'"));
error.ReplaceAll("%filename", inRef.name);
fWin->SetStatusMessage(error.String());
fWin->Unlock();
break;
}
Expand Down Expand Up @@ -391,6 +408,9 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
B_TRANSLATE("Audio quality not supported"));
fWin->Unlock();
}
} else {
fWin->SetStatusMessage(
B_TRANSLATE("Error creating track."));
}

} else if (inFormat.IsVideo() && (videoCodec != NULL)) {
Expand Down Expand Up @@ -465,9 +485,14 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
fWin->SetVideoQualityLabel(videoQualitySupport);
fWin->Unlock();
}
} else {
fWin->SetStatusMessage(
B_TRANSLATE("Error creating video."));
}
} else {
// didn't do anything with the track
fWin->SetStatusMessage(
B_TRANSLATE("Input file not recognized as Audio or Video"));
inFile->ReleaseTrack(inTrack);
}
}
Expand Down
16 changes: 15 additions & 1 deletion src/apps/mediaconverter/MediaConverterWindow.cpp
Expand Up @@ -9,6 +9,7 @@

#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include <Alert.h>
#include <Application.h>
Expand Down Expand Up @@ -1005,6 +1006,19 @@ MediaConverterWindow::_CreateMenu()
void
MediaConverterWindow::_SetOutputFolder(BEntry entry)
{
fOutputDir.SetTo(&entry);
BPath path;
entry.GetPath(&path);
if (access(path.Path(), W_OK) != -1) {
fOutputDir.SetTo(&entry);
} else {
BString errorString(B_TRANSLATE("Error writing to location: %strPath%."
" Defaulting to location: /boot/home"));
errorString.ReplaceFirst("%strPath%", path.Path());
BAlert* alert = new BAlert(B_TRANSLATE("Error"),
errorString.String(), B_TRANSLATE("OK"));
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
fOutputDir.SetTo("/boot/home");
}
TruncateOutputFolderPath();
}

0 comments on commit fdd3fd9

Please sign in to comment.