Why i can read the metaData?



  • my code is
    @
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QUrl>
    #include <QDebug>

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    mediaObjcet = new Phonon::MediaObject;
    audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory,this);
    Phonon::createPath(mediaObjcet,audioOutput);
    QUrl url("X:/music/01-the_little_hands_of_asphalt-oslo-prs.mp3");
    mediaObjcet->setCurrentSource(url);
    playit();
    }

    void MainWindow::playit(){
    QMap<QString, QString> metaData = mediaObjcet->metaData();
    QString title = metaData.value("TITLE");
    qDebug()<<title;
    mediaObjcet->play();
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }
    @

    when i run this pro.the DeBug nothing.



  • OK,now i find how can read it. but i am Chinese. so, when file is Chinese code.the metaData is messy code.even i used the
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF8"));
    QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF8"));
    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF8"));
    how fix it


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.