Changeset 249 for winamp-musepack/trunk/mpc_player.cpp
- Timestamp:
- 03/28/07 17:04:57 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
winamp-musepack/trunk/mpc_player.cpp
r248 r249 21 21 #include <math.h> 22 22 23 #include <sstream> 24 #include <iostream> 25 23 26 #include "in2.h" 24 27 #include "mpc_player.h" 28 #include "resource.h" 25 29 #include <mpc/minimax.h> 26 #include "mpc_info.h" 27 28 #include <tag.h> 29 #include <vcclr.h> 30 31 #include <taglib/tag.h> 30 32 31 33 … … 271 273 } 272 274 273 void 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), 0, strlen(tag->title().toCString(true)), System::Text::Encoding::UTF8); 281 infoBox->txtArtist->Text = gcnew String(tag->artist().toCString(true), 0, strlen(tag->artist().toCString(true)), System::Text::Encoding::UTF8); 282 infoBox->txtAlbum->Text = gcnew String(tag->album().toCString(true), 0, strlen(tag->album().toCString(true)), System::Text::Encoding::UTF8); 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), 0, strlen(tag->genre().toCString(true)), System::Text::Encoding::UTF8); 288 infoBox->txtComment->Text = gcnew String(tag->comment().toCString(true), 0, strlen(tag->comment().toCString(true)), System::Text::Encoding::UTF8); 289 } 290 } 291 292 void 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 } 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 //} 325 326 void mpc_player::initDlg(HWND hDlg) 327 { 328 std::ostringstream tmp; 329 330 tmp << "Streamversion "; 331 tmp << si.stream_version; 332 tmp << "\nEncoder : "; 333 tmp << si.encoder; 334 tmp << "\nProfile : "; 335 tmp << si.profile_name; 336 tmp << "\nPNS : "; 337 if (si.pns) tmp << "on"; 338 else tmp << "off"; 339 tmp << "\nGapless : "; 340 if (si.is_true_gapless) tmp << "on"; 341 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 352 353 SetDlgItemText(hDlg, IDC_STREAM_INFO, tmp.str().c_str()); 354 } 355 356 // Message handler for info box. 357 LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 358 { 359 switch (message) 360 { 361 case WM_INITDIALOG: 362 ((mpc_player *) lParam)->initDlg(hDlg); 363 return TRUE; 364 365 case WM_COMMAND: 366 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 367 { 368 EndDialog(hDlg, LOWORD(wParam)); 369 return TRUE; 370 } 371 break; 372 } 373 return FALSE; 322 374 } 323 375 324 376 int mpc_player::infoDlg(HWND hwnd) 325 377 { 326 mpc_info infoBox(this); 327 System::String ^ tmp; 328 329 tmp = "Streamversion "; 330 tmp += si.stream_version; 331 tmp += "\nEncoder : "; 332 tmp += gcnew String(si.encoder); 333 tmp += "\nProfile : "; 334 tmp += gcnew String(si.profile_name); 335 tmp += "\nPNS : "; 336 tmp += si.pns ? "on" : "off"; 337 tmp += "\nGapless : "; 338 tmp += si.is_true_gapless ? "on" : "off"; 339 tmp += "\nAverage bitrate : "; 340 tmp += floor(si.average_bitrate * 1.e-3 + .5); 341 tmp += " Kbps \nSamplerate : "; 342 tmp += si.sample_freq; 343 tmp += "\nChannels : "; 344 tmp += si.channels; 345 tmp += "\nFile size : "; 346 tmp += si.total_file_length; 347 tmp += " Bytes"; 348 // FIXME : add replay gain info 349 350 infoBox.lblStreamInfo->Text = tmp; 351 352 loadTags(% infoBox); 353 354 infoBox.ShowDialog(); 378 DialogBoxParam(mod->hDllInstance, (LPCTSTR)IDD_INFO_BOX, hwnd, (DLGPROC)About, (LPARAM) this); 379 380 //loadTags(% infoBox); 381 382 //infoBox.ShowDialog(); 355 383 return 0; 356 384 }
Note: See TracChangeset
for help on using the changeset viewer.