Ignore:
Timestamp:
12/25/06 23:45:24 (17 years ago)
Author:
r2d
Message:

added tag writing, but TagLib::FileRef::save() make all crash and I'm too lazy to debug

File:
1 edited

Legend:

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

    r191 r192  
    2727
    2828#include <tag.h>
    29 
    30 using namespace winamp_musepack;
     29#include <vcclr.h>
     30
    3131
    3232mpc_player::mpc_player(In_Module * in_mod)
     
    271271}
    272272
     273void mpc_player::loadTags(mpc_info ^ infoBox)
     274{
     275        if(tag_file == 0)
     276                tag_file = new TagLib::FileRef(lastfn, false);
     277
     278        if (!tag_file->isNull() && tag_file->tag()) {
     279                TagLib::Tag *tag = tag_file->tag();
     280                infoBox->txtTitle->Text = gcnew String(tag->title().toCString(true));
     281                infoBox->txtArtist->Text = gcnew String(tag->artist().toCString(true));
     282                infoBox->txtAlbum->Text = gcnew String(tag->album().toCString(true));
     283                infoBox->txtYear->Text = "";
     284                infoBox->txtYear->Text += tag->year();
     285                infoBox->txtTrack->Text = "";
     286                infoBox->txtTrack->Text += tag->track();
     287                infoBox->comboGenre->Text = gcnew String(tag->genre().toCString(true));
     288                infoBox->txtComment->Text = gcnew String(tag->comment().toCString(true));
     289        }
     290}
     291
     292void mpc_player::writeTags(mpc_info ^ infoBox)
     293{
     294        if (!tag_file->isNull() && tag_file->tag()) {
     295                TagLib::Tag *tag = tag_file->tag();
     296
     297                pin_ptr<const wchar_t> wch = PtrToStringChars(infoBox->txtTitle->Text);
     298                tag->setTitle(wch);
     299
     300                wch = PtrToStringChars(infoBox->txtArtist->Text);
     301                tag->setArtist(wch);
     302
     303                wch = PtrToStringChars(infoBox->txtAlbum->Text);
     304                tag->setAlbum(wch);
     305
     306                wch = PtrToStringChars(infoBox->txtYear->Text);
     307                TagLib::String year(wch);
     308                tag->setYear(year.toInt());
     309
     310                wch = PtrToStringChars(infoBox->txtTrack->Text);
     311                TagLib::String track(wch);
     312                tag->setTrack(track.toInt());
     313
     314                wch = PtrToStringChars(infoBox->comboGenre->Text);
     315                tag->setGenre(wch);
     316
     317                wch = PtrToStringChars(infoBox->txtComment->Text);
     318                tag->setComment(wch);
     319
     320                tag_file->save(); // FIXME : make all crash
     321        }
     322}
     323
    273324int mpc_player::infoDlg(HWND hwnd)
    274325{
    275         mpc_info infoBox;
     326        mpc_info infoBox(this);
    276327        System::String ^ tmp;
    277328
     
    299350        infoBox.lblStreamInfo->Text = tmp;
    300351
    301 
    302         if(tag_file == 0)
    303                 tag_file = new TagLib::FileRef(lastfn, false);
    304 
    305         if (!tag_file->isNull() && tag_file->tag()) {
    306                 TagLib::Tag *tag = tag_file->tag();
    307                 infoBox.txtTitle->Text = gcnew String(tag->title().toCString(true));
    308                 infoBox.txtArtist->Text = gcnew String(tag->artist().toCString(true));
    309                 infoBox.txtAlbum->Text = gcnew String(tag->album().toCString(true));
    310                 infoBox.txtYear->Text += tag->year();
    311                 infoBox.txtTrack->Text += tag->track();
    312                 infoBox.comboGenre->Text = gcnew String(tag->genre().toCString(true));
    313                 infoBox.txtComment->Text = gcnew String(tag->comment().toCString(true));
    314         }
     352        loadTags(% infoBox);
    315353
    316354        infoBox.ShowDialog();
Note: See TracChangeset for help on using the changeset viewer.