QWebView problem with flash



  • Hi,
    I had written a music player application in C# and I have decided to rewrite it in QT, but I have a huge problem with QWebView (which is similar to WebBrowser in C#). My application uses a flash player from the website.

    WebBrowser's (C#) WebBrowserProgressChangedEvent sends to me the signal (-1), when the flash player has just finished his job, but QWebView doesn't. In this application I have to know when a current track is finished, to start the next one, so please help me.

    How can I solve this problem?

    I have attached print screens from both applications (they say how WebBrowserProgressChangedEvent (from C#) and loadProgress(int) (from QT) signals are changing) and source code.

    C# application
    !http://imageswink.com/out.php/t3493_c-.jpg!:http://imageswink.com/show.php/3493_c-.jpg.html

    QT application
    !http://imageswink.com/out.php/t3494_qt.jpg!:http://imageswink.com/show.php/3494_qt.jpg.html

    MainWindow.h
    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QtGui/QListWidget>
    #include <QtGui/QVBoxLayout>
    #include <QtGui/QWidget>
    #include <QtWebKit/QWebView>

    class MainWindow : public QWidget
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    private:
    QVBoxLayout *verticalLayout;
    QWebView *webView;
    QListWidget *listWidget;

    void setupUi(QWidget *MainWindow);
    

    private slots:
    void progressChanged(int progress);
    };

    #endif // MAINWINDOW_H@
    MainWindow.cpp
    @#include "MainWindow.h"

    MainWindow::MainWindow(QWidget *parent) : QWidget(parent)
    {
    setupUi(this);
    connect(webView, SIGNAL(loadProgress(int)), this, SLOT(progressChanged(int)));
    }

    MainWindow::~MainWindow()
    {
    }

    void MainWindow::progressChanged(int progress)
    {
    listWidget->addItem(QString::number(progress));
    }

    void MainWindow::setupUi(QWidget *widget)
    {
    webView = new QWebView(widget);
    webView->setFixedSize(250, 70);
    webView->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
    webView->setUrl(QUrl("http://w618.wrzuta.pl/audio.swf?key=aL9BKZ2y9Lb&host=wrzuta.pl&autoplay=y"));

    listWidget = new QListWidget(widget);
    
    verticalLayout = new QVBoxLayout(widget);
    verticalLayout->addWidget(webView);
    verticalLayout->addWidget(listWidget);
    
    widget->setLayout(verticalLayout);
    

    }@



  • If the flash players sends any kind of event you can get from JavaScript, you could add a C++ object to the context and add an event listener calling that object.

    bq. WebBrowser’s (C#) WebBrowserProgressChangedEvent sends to me the signal (-1), when the flash player has just finished his job

    How does that work? You receive the event when the content has finished playing? or finished loading? I guess you could subclass QNetworkAccessManager and wait for all request to be finished.


Log in to reply
 

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