int
main(int argc, char** argv) {
    std::string basePath(Poco::Environment::get("OMMTEST"));
    Poco::DirectoryIterator end;

    std::vector<std::string> videoFiles;
    std::string videoPath = basePath + "/video";
    Poco::DirectoryIterator videoDir(videoPath);
    while(videoDir != end) {
        videoFiles.push_back(videoPath + "/" + videoDir.name());
        ++videoDir;
    }
    
    std::vector<std::string> audioFiles;
    std::string audioPath = basePath + "/audio";
    Poco::DirectoryIterator audioDir(audioPath);
    while(audioDir != end) {
        audioFiles.push_back(audioPath + "/" + audioDir.name());
        ++audioDir;
    }
    
    std::vector<std::string> liveTv;
    for (int i = 0; i < 10; ++i) {
        liveTv.push_back(liveStreamAddress + Poco::NumberFormatter::format(i) + "$0");
    }
    
    std::vector<std::string> allStreams;
    for (std::vector<std::string>::iterator it = audioFiles.begin(); it != audioFiles.end(); ++it) {
        allStreams.push_back(*it);
    }
    for (std::vector<std::string>::iterator it = videoFiles.begin(); it != videoFiles.end(); ++it) {
        allStreams.push_back(*it);
    }
    
    AvStreamEngine engine;
    engine.createPlayer();
    
//     seqPlay(engine, audioFiles);
//     randPlay(engine, audioFiles);
//     seqPlay(engine, videoFiles);
//     randPlay(engine, videoFiles);
//    seqPlay(engine, liveTv);
    randPlay(engine, liveTv, 20);
//      seqPlay(engine, allStreams);
//      randPlay(engine, allStreams);
    
    engine.destructPlayer();
}
Example #2
0
//打开视频文件
void VideoPlayer::openVideoFile(QString file)       //默认参数 file=""
{
    QStringList openVideoFileNames;
    QString absolutePath = QFileInfo(file).absolutePath();
    if (file.isEmpty())
    {
        openVideoFileNames.append(QFileDialog::getOpenFileName(this));
    }
    else
    {
        QDir videoDir(absolutePath);
        QStringList tempFiles = videoDir.entryList(QDir::Files);    //获得文件名
        for (int indext=0; indext<tempFiles.length(); indext++)
        {
            openVideoFileNames.append(QFileInfo(tempFiles.at(indext)).absoluteFilePath());  //将文件名转换成绝对路径
        }

    }
    if (openVideoFileNames.isEmpty())
    {
        return;
    }

    //添加到 playlist 中
    for(int indext=0; indext<openVideoFileNames.length(); indext++)
    {
        playlist_list.at(1)->addMedia(QUrl::fromLocalFile(tr("%1").arg(openVideoFileNames.at(indext))));
    }
    for(int indext=0; indext<openVideoFileNames.length(); indext++)
    {
        if(openVideoFileNames.at(indext) == file)
        {
            playlist_list.at(1)->setCurrentIndex(indext);
            break;
        }
    }
    player->play();
    QStringList fileBaseNames;
    for(int indext=0; indext<playlist_list.at(1)->mediaCount(); indext++)
    {
        fileBaseNames.append(playlist_list.at(1)->media(indext).canonicalUrl().fileName());
    }
    videoContral->addVideoList(fileBaseNames);
    lab_background->setStyleSheet("border-image: url(:/Images/black.png);");
    tbn_openVideoFile->hide();
}