Ignore:
Timestamp:
07/18/14 07:49:27 (8 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0.3, releng/10.1, releng/10.1.1
Children:
b5bed61
Parents:
ba6f48c
Message:

Add auto-detection of multimedia file extensions into lumina-fm, and also add a function into libLumina for converting a mime-type into a list of file extensions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lumina/lumina-fm/MainUI.cpp

    r4333764 r0494142  
    188188  connect(mediaObj, SIGNAL(tick(qint64)), this, SLOT(playerTimeChanged(qint64)) ); 
    189189  connect(mediaObj, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(playerStateChanged(Phonon::State, Phonon::State)) ); 
    190    
     190  connect(mediaObj, SIGNAL(hasVideoChanged(bool)), this, SLOT(playerVideoAvailable(bool)) ); 
    191191  //Special Keyboard Shortcuts 
    192192  connect(nextTabLShort, SIGNAL(activated()), this, SLOT( prevTab() ) ); 
     
    387387  QDir dir(getCurrentDir()); 
    388388  if(multiFilter.isEmpty()){ 
    389     //hard-code the multimedia filter at the moment - need to find a way to read this from Phonon directly later 
    390     multiFilter << "*.mp3" << "*.ogg" << "*.mp4" << "*.mp4a" << "*.wmv" << "*.mov" << "*.flv"; 
     389    QStringList mimes = Phonon::BackendCapabilities::availableMimeTypes(); 
     390    mimes = mimes.filter("audio/") + mimes.filter("video/"); 
     391    for(int i=0; i<mimes.length(); i++){ 
     392      multiFilter << LXDG::findFilesForMime(mimes[i]); 
     393    } 
     394    multiFilter.removeDuplicates(); 
    391395    qDebug() << "Supported Multimedia Formats:" << multiFilter; 
    392396  } 
     
    977981void MainUI::playerStart(){ 
    978982  if(ui->stackedWidget->currentWidget()!=ui->page_audioPlayer){ return; } //don't play if not in the player 
    979   if(mediaObj->state()==Phonon::StoppedState || mediaObj->state()==Phonon::ErrorState || (playerFile->fileName().section("/",-1) != ui->combo_player_list->currentText()) || playerFile->isOpen() ){ 
     983   
     984  if(mediaObj->state()==Phonon::PausedState){ 
     985    mediaObj->play(); 
     986  }else if(mediaObj->state()==Phonon::StoppedState || mediaObj->state()==Phonon::ErrorState || (playerFile->fileName().section("/",-1) != ui->combo_player_list->currentText()) || playerFile->isOpen() ){ 
    980987    mediaObj->stop(); 
    981988    //Get the selected file path 
     
    990997      mediaObj->play(); 
    991998    } 
    992   }else if(mediaObj->state()==Phonon::PausedState){ 
    993     mediaObj->play(); 
    994   } 
    995  
     999  } 
    9961000} 
    9971001 
     
    10251029  bool running = false; 
    10261030  bool showVideo = false; 
     1031  QString msg; 
    10271032  switch(newstate){ 
    10281033    case Phonon::LoadingState: 
     
    10321037    case Phonon::PlayingState: 
    10331038        running=true; 
    1034         if(mediaObj->hasVideo()){  
    1035           showVideo=true; 
    1036         }else{ 
    1037           QString msg = mediaObj->metaData(Phonon::TitleMetaData).join(" "); 
    1038           if(msg.simplified().isEmpty()){ msg = playerFile->fileName().section("/",-1); } 
    1039           ui->label_player_novideo->setText(tr("Playing:")+"\n"+msg); 
    1040         } 
     1039        showVideo = mediaObj->hasVideo(); 
     1040        msg = mediaObj->metaData(Phonon::TitleMetaData).join(" "); 
     1041        if(msg.simplified().isEmpty()){ msg = playerFile->fileName().section("/",-1); } 
     1042        ui->label_player_novideo->setText(tr("Playing:")+"\n"+msg); 
    10411043        break; 
    10421044    case Phonon::BufferingState: 
     
    10621064} 
    10631065 
     1066void MainUI::playerVideoAvailable(bool showVideo){ 
     1067  ui->label_player_novideo->setVisible(!showVideo); 
     1068  videoDisplay->setVisible(showVideo);   
     1069} 
     1070 
    10641071void MainUI::playerTimeChanged(qint64 ctime){ 
    1065   //qDebug() << "Time:" << msToText(ctime) << msToText(mediaObj->totalTime()) << msToText(mediaObj->remainingTime()) << mediaObj->isSeekable(); 
    1066   ui->label_player_runstats->setText( msToText(ctime)+"/"+msToText(mediaObj->totalTime()) ); 
     1072  if(playerTTime=="0:00" || playerTTime.isEmpty()){ playerTTime = msToText(mediaObj->totalTime()); } //only calculate as necessary 
     1073  //qDebug() << "Time:" << msToText(ctime) << playerTTime << mediaObj->isSeekable() << mediaObj->hasVideo(); 
     1074  ui->label_player_runstats->setText( msToText(ctime)+"/"+playerTTime ); 
    10671075} 
    10681076 
Note: See TracChangeset for help on using the changeset viewer.