Ticket #6497: mediaconv2.diff

File mediaconv2.diff, 4.2 KB (added by Barrett, 13 years ago)
  • src/apps/mediaconverter/MediaConverterWindow.cpp

     
    271271MediaConverterWindow::MessageReceived(BMessage* msg)
    272272{
    273273    status_t status;
    274     entry_ref ref;
    275274    entry_ref inRef;
    276275
    277276    BString string, string2;
    278277
    279     // TODO: For preview, launch the default file app instead of hardcoded
    280     // MediaPlayer
    281     BEntry entry("/boot/system/apps/MediaPlayer", true);
    282278    char buffer[40];
    283279    char buffer2[B_PATH_NAME_LENGTH];
    284280    const char* argv[3];
     
    431427            break;
    432428
    433429        case PREVIEW_MESSAGE:
    434             entry.GetRef(&ref);
    435430            string = "";
    436431            string << fStartDurationTC->Text();
    437432            string << "000";
     
    450445                argv[2] = buffer2;
    451446            }
    452447
    453             status = be_roster->Launch(&ref, 3, argv);
     448            status = be_roster->Launch(
     449                "application/x-vnd.Haiku-MediaPlayer",
     450                3, (char**)argv, NULL);
    454451
    455             if (status != B_OK) {
     452            if (status != B_OK && status != B_ALREADY_RUNNING) {
    456453                string2 << LAUNCH_ERROR << strerror(status);
    457454                (new BAlert("", string2.String(), OK_LABEL))->Go();
    458455            }
     
    756753    fStartDurationTC->SetEnabled(enabled);
    757754    fEndDurationTC->SetEnabled(enabled);
    758755
    759     fInfoView->Update(file, _ref);
     756    if (enabled)
     757        fInfoView->Update(file, _ref);
    760758
    761759    // HACK: get the fInfoView to update the duration "synchronously"
    762760    UpdateIfNeeded();
  • src/apps/mediaconverter/MediaConverterApp.cpp

     
    1010#include <string.h>
    1111
    1212#include <Alert.h>
     13#include <fs_attr.h>
    1314#include <MediaFile.h>
    1415#include <MediaTrack.h>
    1516#include <Mime.h>
     
    105106    // from Open dialog or drag & drop
    106107
    107108    while (msg->FindRef("refs", i++, &ref) == B_OK) {
     109
    108110        uint32 flags = 0; // B_MEDIA_FILE_NO_READ_AHEAD
    109111        BMediaFile* file = new(std::nothrow) BMediaFile(&ref, flags);
     112
    110113        if (file == NULL || file->InitCheck() != B_OK) {
    111114            errorFiles << ref.name << "\n";
    112115            errors++;
     
    122125
    123126    if (errors) {
    124127        BString alertText;
    125         alertText << errors << ((errors > 1) ? FILES : FILE)
     128        alertText << errors << " " << ((errors > 1) ? FILES : FILE)
    126129                << NOTRECOGNIZE << "\n";
    127130        alertText << errorFiles;
    128131        BAlert* alert = new BAlert(ERROR_LOAD_STRING, alertText.String(),
     
    175178
    176179// #pragma mark -
    177180
    178 
    179181BEntry
    180182MediaConverterApp::_CreateOutputFile(BDirectory directory,
    181183    entry_ref* ref, media_file_format* outputFormat)
  • src/apps/mediaconverter/MediaConverterApp.h

     
    3737            BEntry              _CreateOutputFile(BDirectory directory,
    3838                                    entry_ref* ref,
    3939                                    media_file_format* outputFormat);
    40    
     40
    4141    static  int32               _RunConvertEntry(void* castToMediaConverterApp);
    4242            void                _RunConvert();
    4343            status_t            _ConvertFile(BMediaFile* inFile,
  • src/apps/mediaconverter/MediaFileInfoView.cpp

     
    151151
    152152    fMediaFile = file;
    153153
    154     if (file != NULL && ref != NULL)
     154    if (file != NULL && ref != NULL) {
    155155        fRef = *ref;
    156     else
     156        status_t ret = fInfo.LoadInfo(file);
     157        if (ret != B_OK) {
     158            BString error("An error has occurred reading the "
     159                "file info.\n\nError : ");
     160            error << strerror(ret);
     161            BAlert* alert = new BAlert("File Error", error.String(),
     162                "OK");
     163            alert->Go(NULL);
     164        }
     165    } else {
    157166        fRef = entry_ref();
    158 
    159     status_t ret = fInfo.LoadInfo(file);
    160     if (ret != B_OK) {
    161         BString error("An error has occurred reading the "
    162             "file info.\n\nError : ");
    163         error << strerror(ret);
    164         BAlert* alert = new BAlert("File Error", error.String(),
    165             "OK");
    166         alert->Go(NULL);
    167167    }
    168 
    169168    InvalidateLayout();
    170169    Invalidate();
    171170}