Ignore:
Timestamp:
03/28/07 19:19:56 (17 years ago)
Author:
r2d
Message:
  • can now read file tags and display
  • doesn't work with accentuated file names (don't know why, taglib issue ?)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • winamp-musepack/trunk/mpc_player.cpp

    r249 r250  
    144144                        }
    145145                        WaitForSingleObject(wait_event, 100);           // give a little CPU time back to the system.
    146                 } else if (mod->outMod->CanWrite() >= (MPC_FRAME_LENGTH * sizeof(short) * si.channels)*(mod->dsp_isactive()?2:1)) {
     146                } else if (mod->outMod->CanWrite() >= (int)((MPC_FRAME_LENGTH * sizeof(short) * si.channels)*(mod->dsp_isactive()?2:1))) {
    147147                        // CanWrite() returns the number of bytes you can write, so we check that
    148148                        // to the block size. the reason we multiply the block size by two if
     
    255255        // dividing by 1000 for the first parameter of setinfo makes it
    256256        // display 'H'... for hundred.. i.e. 14H Kbps.
    257         mod->SetInfo(si.average_bitrate / 1000, si.sample_freq / 1000, si.channels, 1);
     257        mod->SetInfo((int)(si.average_bitrate / 1000), si.sample_freq / 1000, si.channels, 1);
    258258
    259259        // initialize visualization stuff
     
    273273}
    274274
    275 //void mpc_player::loadTags(mpc_info ^ infoBox)
    276 //{
    277 //      if(tag_file == 0)
    278 //              tag_file = new TagLib::FileRef(lastfn, false);
    279 //
    280 //      if (!tag_file->isNull() && tag_file->tag()) {
    281 //              TagLib::Tag *tag = tag_file->tag();
    282 //              infoBox->txtTitle->Text = gcnew String(tag->title().toCString(true), 0, strlen(tag->title().toCString(true)), System::Text::Encoding::UTF8);
    283 //              infoBox->txtArtist->Text = gcnew String(tag->artist().toCString(true), 0, strlen(tag->artist().toCString(true)), System::Text::Encoding::UTF8);
    284 //              infoBox->txtAlbum->Text = gcnew String(tag->album().toCString(true), 0, strlen(tag->album().toCString(true)), System::Text::Encoding::UTF8);
    285 //              infoBox->txtYear->Text = "";
    286 //              infoBox->txtYear->Text += tag->year();
    287 //              infoBox->txtTrack->Text = "";
    288 //              infoBox->txtTrack->Text += tag->track();
    289 //              infoBox->comboGenre->Text = gcnew String(tag->genre().toCString(true), 0, strlen(tag->genre().toCString(true)), System::Text::Encoding::UTF8);
    290 //              infoBox->txtComment->Text = gcnew String(tag->comment().toCString(true), 0, strlen(tag->comment().toCString(true)), System::Text::Encoding::UTF8);
    291 //      }
    292 //}
    293 
    294 //void mpc_player::writeTags(mpc_info ^ infoBox)
    295 //{
    296 //      if (!tag_file->isNull() && tag_file->tag()) {
    297 //              TagLib::Tag *tag = tag_file->tag();
    298 //
    299 //              pin_ptr<const wchar_t> wch = PtrToStringChars(infoBox->txtTitle->Text);
    300 //              tag->setTitle(wch);
    301 //
    302 //              wch = PtrToStringChars(infoBox->txtArtist->Text);
    303 //              tag->setArtist(wch);
    304 //
    305 //              wch = PtrToStringChars(infoBox->txtAlbum->Text);
    306 //              tag->setAlbum(wch);
    307 //
    308 //              wch = PtrToStringChars(infoBox->txtYear->Text);
    309 //              TagLib::String year(wch);
    310 //              tag->setYear(year.toInt());
    311 //
    312 //              wch = PtrToStringChars(infoBox->txtTrack->Text);
    313 //              TagLib::String track(wch);
    314 //              tag->setTrack(track.toInt());
    315 //
    316 //              wch = PtrToStringChars(infoBox->comboGenre->Text);
    317 //              tag->setGenre(wch);
    318 //
    319 //              wch = PtrToStringChars(infoBox->txtComment->Text);
    320 //              tag->setComment(wch);
    321 //
    322 //              tag_file->save(); // FIXME : make all crash
    323 //      }
    324 //}
     275void mpc_player::writeTags(HWND hDlg)
     276{
     277        if (!tag_file->isNull() && tag_file->tag()) {
     278                TagLib::Tag *tag = tag_file->tag();
     279
     280                //tag->setTitle(wch);
     281                //tag->setArtist(wch);
     282                //tag->setAlbum(wch);
     283
     284                //TagLib::String year(wch);
     285                //tag->setYear(year.toInt());
     286
     287                //TagLib::String track(wch);
     288                //tag->setTrack(track.toInt());
     289
     290                //tag->setGenre(wch);
     291                //tag->setComment(wch);
     292
     293                tag_file->save(); // FIXME : make all crash
     294        }
     295}
    325296
    326297void mpc_player::initDlg(HWND hDlg)
     
    328299        std::ostringstream tmp;
    329300
    330         tmp << "Streamversion ";
    331         tmp << si.stream_version;
    332         tmp << "\nEncoder : ";
    333         tmp << si.encoder;
    334         tmp << "\nProfile : ";
    335         tmp << si.profile_name;
     301        tmp << "Streamversion " << si.stream_version;
     302        tmp << "\nEncoder : " << si.encoder;
     303        tmp << "\nProfile : " << si.profile_name;
    336304        tmp << "\nPNS : ";
    337305        if (si.pns) tmp << "on";
     
    340308        if (si.is_true_gapless) tmp << "on";
    341309        else tmp << "off";
    342         tmp << "\nAverage bitrate : ";
    343         tmp << floor(si.average_bitrate * 1.e-3 + .5);
    344         tmp << " Kbps \nSamplerate : ";
    345         tmp << si.sample_freq;
    346         tmp << "\nChannels : ";
    347         tmp << si.channels;
    348         tmp << "\nFile size : ";
    349         tmp << si.total_file_length;
    350         tmp << " Bytes";
    351         //// FIXME : add replay gain info
     310        tmp << "\nAverage bitrate : " << floor(si.average_bitrate * 1.e-3 + .5) << " Kbps";
     311        tmp << "\nSamplerate : " << si.sample_freq;
     312        tmp << "\nChannels : " << si.channels;
     313        tmp << "\nFile size : " << si.total_file_length << " Bytes";
     314        //// FIXME : add replay gain info, lenth (min:sec), sample number
    352315
    353316        SetDlgItemText(hDlg, IDC_STREAM_INFO, tmp.str().c_str());
     317
     318        if(tag_file == 0)
     319                tag_file = new TagLib::FileRef(lastfn, false);
     320
     321        if (!tag_file->isNull() && tag_file->tag()) {
     322                TagLib::Tag *tag = tag_file->tag();
     323                SetDlgItemText(hDlg, IDC_TITLE, tag->title().toCString(true));
     324                SetDlgItemText(hDlg, IDC_ARTIST, tag->artist().toCString(true));
     325                SetDlgItemText(hDlg, IDC_ALBUM, tag->album().toCString(true));
     326                tmp.str("");
     327                tmp << tag->year();
     328                SetDlgItemText(hDlg, IDC_YEAR, tmp.str().c_str());
     329                tmp.str("");
     330                tmp << tag->track();
     331                SetDlgItemText(hDlg, IDC_TRACK, tmp.str().c_str());
     332                SetDlgItemText(hDlg, IDC_GENRE, tag->genre().toCString(true));
     333                SetDlgItemText(hDlg, IDC_COMMENT, tag->comment().toCString(true));
     334        }
    354335}
    355336
     
    360341        {
    361342        case WM_INITDIALOG:
     343                SetWindowLong(hDlg, DWL_USER, lParam);
    362344                ((mpc_player *) lParam)->initDlg(hDlg);
    363345                return TRUE;
    364346
    365347        case WM_COMMAND:
    366                 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
    367                 {
     348                if (LOWORD(wParam) == IDC_CANCEL || LOWORD(wParam) == IDCANCEL) {
     349                        EndDialog(hDlg, LOWORD(wParam));
     350                        return TRUE;
     351                } else if (LOWORD(wParam) == IDC_RELOAD) {
     352                        // FIXME : this will not work on X64
     353                        ((mpc_player*)GetWindowLong(hDlg, DWL_USER))->initDlg(hDlg);
     354                } else if (LOWORD(wParam) == IDC_SAVE) {
     355                        ((mpc_player*)GetWindowLong(hDlg, DWL_USER))->writeTags(hDlg);
    368356                        EndDialog(hDlg, LOWORD(wParam));
    369357                        return TRUE;
Note: See TracChangeset for help on using the changeset viewer.