Fixed the flash fallback for non existent youtube html5 videos

parent 95bf16aa
......@@ -43,6 +43,7 @@
#include <QString>
#include <QPalette>
#include <QDragMoveEvent>
#include <QNetworkReply>
#include <iostream>
#include "ipcmsg.h"
#include "jsbridge.h"
......@@ -113,6 +114,20 @@ MainWin::~MainWin()
}
void MainWin::httpResponseFinished(QNetworkReply * reply)
{
QString urls = reply->url().toString();
//std::cout << "AAAA " << reply->error() << " URI " << urls.toStdString() << std::endl;;
if(yt_is_open && urls.contains("stream_204") && urls.contains("youtube") && urls.contains("html5=1"))
{
QString urlstr = yt->url().toString();
std::cout << "NO HTML5 FOR THIS YOUTUBE VIDEO " << urlstr.toStdString() << std::endl;
std::cout << "Reopen with " << urlstr.remove("html5=1&").toStdString() << std::endl;
yt->load(QUrl(urlstr.remove("html5=1&")));
}
}
void MainWin::handle_corestarted(SKMessage &msg)
{
msg.handle = "connectTelescopes";
......@@ -194,6 +209,9 @@ void MainWin::handle_youtubevideo(SKMessage &msg)
QWebPage *newWeb = new QWebPage(yt);
//ReferredNetworkAccessManager nam;
ReferredNetworkAccessManager *nam = new ReferredNetworkAccessManager();
connect(nam, SIGNAL(finished(QNetworkReply *)), this, SLOT(httpResponseFinished(QNetworkReply *)));
newWeb->setNetworkAccessManager(nam);
//#endif
......
......@@ -45,6 +45,7 @@
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QIODevice>
#include <QNetworkReply>
#include <ipcmsg.h>
#include "webwin.h"
#include "jsbridge.h"
......@@ -76,6 +77,7 @@ class MainWin : public SkylivexWin
void handle_closeyoutube(SKMessage &msg);
public slots:
void ytclosesignal(); // This slot is needed to close the special youtube window
void httpResponseFinished(QNetworkReply * reply);
};
......
......@@ -43,6 +43,7 @@
#include <QString>
#include <QPalette>
#include <QDragMoveEvent>
//#include <QNetworkReply>
#include <iostream>
#include "ipcmsg.h"
#include "jsbridge.h"
......@@ -70,6 +71,8 @@
WebWin::WebWin(QString &htmlfile)
: QWebView(0)
{
......@@ -112,6 +115,15 @@ WebWin::~WebWin()
}
/*
void WebWin::httpResponseFinished(QNetworkReply * reply)
{
if(reply->error()==204)
std::cout << "NO FLASH!" << std::endl;
}
}
*/
void WebWin::closeEvent(QCloseEvent *event)
{
emit closingWindow();
......@@ -126,6 +138,7 @@ QWebView* WebWin::createWindow(QWebPage::WebWindowType type)
QWebPage *newWeb = new QWebPage(wv);
//#endif
//connect(newWeb->networkAccessManager(), SIGNAL(finished(QNetworkReply *)), this, SLOT(httpResponseFinished(QNetworkReply *)));
wv->setPage(newWeb);
wv->setAttribute(Qt::WA_DeleteOnClose, true);
if (type == QWebPage::WebModalDialog)
......@@ -138,7 +151,6 @@ QWebView* WebWin::createWindow(QWebPage::WebWindowType type)
SKMessage msg("newwindow", qobject_cast<SkylivexWin *>(wv));
sendMessage(msg);
wv->show();
return wv;
}
......
......@@ -42,6 +42,7 @@
#include <QHash>
#include <QString>
#include <QObject>
//#include <QNetworkReply>
#include <ipcmsg.h>
#include "jsbridge.h"
......@@ -102,6 +103,7 @@ class WebWin : public QWebView
public slots:
void msgFromCore(SKMessage &msg);
//void httpResponseFinished(QNetworkReply * reply);
signals:
void putMessage(SKMessage &msg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment