#include <QApplication>
#include <QDebug>
#include <QFileDialog>
#include <QHBoxLayout>
#include <QLabel>
#include <QMainWindow>
#include <QMessageBox>
#include <QPushButton>
#include <QSlider>
#include <QTimer>
#include <QVBoxLayout>
#include <QDir>
#include <QStandardPaths>

#include "code/base/logger.h"

#include "code/player/SimplePlayerWindow.h"

int main(int argc, char* argv[])
{
    // 初始化日志系统
    QString logPath = "./AV_Player/log.txt";
    QDir().mkpath(QFileInfo(logPath).absolutePath());
    
    av::Logger::initialize(logPath.toStdString(), av::LogLevel::DEBUG, true, true);
    
    QApplication app(argc, argv);
    
    // 设置应用程序信息
    app.setApplicationName("AV Player");
    app.setApplicationVersion("1.0.0");
    app.setOrganizationName("AV Framework");

    qDebug() << "=== AV Player Integration Example Started ===";
    qDebug() << "Log file:" << logPath;
    qDebug() << "This example demonstrates how to integrate the new player core with Qt UI";
    
    // 检查FFmpeg库
    qDebug() << "Checking FFmpeg library availability...";
    
    // 创建并显示播放器窗口
    try {
        SimplePlayerWindow window;
        window.show();
        
        qDebug() << "Player window created and shown successfully";
        
        return app.exec();
    } catch (const std::exception& e) {
        qCritical() << "Exception during player initialization:" << e.what();
        QMessageBox::critical(nullptr, "Error", 
            QString("Failed to initialize player: %1").arg(e.what()));
        return -1;
    } catch (...) {
        qCritical() << "Unknown exception during player initialization";
        QMessageBox::critical(nullptr, "Error", "Unknown error during player initialization");
        return -1;
    }
}
