Fixed the flash fallback for non existent youtube html5 videos

parent 95bf16aa
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <QString> #include <QString>
#include <QPalette> #include <QPalette>
#include <QDragMoveEvent> #include <QDragMoveEvent>
#include <QNetworkReply>
#include <iostream> #include <iostream>
#include "ipcmsg.h" #include "ipcmsg.h"
#include "jsbridge.h" #include "jsbridge.h"
...@@ -113,6 +114,20 @@ MainWin::~MainWin() ...@@ -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) void MainWin::handle_corestarted(SKMessage &msg)
{ {
msg.handle = "connectTelescopes"; msg.handle = "connectTelescopes";
...@@ -194,6 +209,9 @@ void MainWin::handle_youtubevideo(SKMessage &msg) ...@@ -194,6 +209,9 @@ void MainWin::handle_youtubevideo(SKMessage &msg)
QWebPage *newWeb = new QWebPage(yt); QWebPage *newWeb = new QWebPage(yt);
//ReferredNetworkAccessManager nam; //ReferredNetworkAccessManager nam;
ReferredNetworkAccessManager *nam = new ReferredNetworkAccessManager(); ReferredNetworkAccessManager *nam = new ReferredNetworkAccessManager();
connect(nam, SIGNAL(finished(QNetworkReply *)), this, SLOT(httpResponseFinished(QNetworkReply *)));
newWeb->setNetworkAccessManager(nam); newWeb->setNetworkAccessManager(nam);
//#endif //#endif
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkRequest> #include <QNetworkRequest>
#include <QIODevice> #include <QIODevice>
#include <QNetworkReply>
#include <ipcmsg.h> #include <ipcmsg.h>
#include "webwin.h" #include "webwin.h"
#include "jsbridge.h" #include "jsbridge.h"
...@@ -76,6 +77,7 @@ class MainWin : public SkylivexWin ...@@ -76,6 +77,7 @@ class MainWin : public SkylivexWin
void handle_closeyoutube(SKMessage &msg); void handle_closeyoutube(SKMessage &msg);
public slots: public slots:
void ytclosesignal(); // This slot is needed to close the special youtube window void ytclosesignal(); // This slot is needed to close the special youtube window
void httpResponseFinished(QNetworkReply * reply);
}; };
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <QString> #include <QString>
#include <QPalette> #include <QPalette>
#include <QDragMoveEvent> #include <QDragMoveEvent>
//#include <QNetworkReply>
#include <iostream> #include <iostream>
#include "ipcmsg.h" #include "ipcmsg.h"
#include "jsbridge.h" #include "jsbridge.h"
...@@ -70,6 +71,8 @@ ...@@ -70,6 +71,8 @@
WebWin::WebWin(QString &htmlfile) WebWin::WebWin(QString &htmlfile)
: QWebView(0) : QWebView(0)
{ {
...@@ -112,6 +115,15 @@ WebWin::~WebWin() ...@@ -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) void WebWin::closeEvent(QCloseEvent *event)
{ {
emit closingWindow(); emit closingWindow();
...@@ -126,6 +138,7 @@ QWebView* WebWin::createWindow(QWebPage::WebWindowType type) ...@@ -126,6 +138,7 @@ QWebView* WebWin::createWindow(QWebPage::WebWindowType type)
QWebPage *newWeb = new QWebPage(wv); QWebPage *newWeb = new QWebPage(wv);
//#endif //#endif
//connect(newWeb->networkAccessManager(), SIGNAL(finished(QNetworkReply *)), this, SLOT(httpResponseFinished(QNetworkReply *)));
wv->setPage(newWeb); wv->setPage(newWeb);
wv->setAttribute(Qt::WA_DeleteOnClose, true); wv->setAttribute(Qt::WA_DeleteOnClose, true);
if (type == QWebPage::WebModalDialog) if (type == QWebPage::WebModalDialog)
...@@ -138,7 +151,6 @@ QWebView* WebWin::createWindow(QWebPage::WebWindowType type) ...@@ -138,7 +151,6 @@ QWebView* WebWin::createWindow(QWebPage::WebWindowType type)
SKMessage msg("newwindow", qobject_cast<SkylivexWin *>(wv)); SKMessage msg("newwindow", qobject_cast<SkylivexWin *>(wv));
sendMessage(msg); sendMessage(msg);
wv->show(); wv->show();
return wv; return wv;
} }
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <QHash> #include <QHash>
#include <QString> #include <QString>
#include <QObject> #include <QObject>
//#include <QNetworkReply>
#include <ipcmsg.h> #include <ipcmsg.h>
#include "jsbridge.h" #include "jsbridge.h"
...@@ -102,6 +103,7 @@ class WebWin : public QWebView ...@@ -102,6 +103,7 @@ class WebWin : public QWebView
public slots: public slots:
void msgFromCore(SKMessage &msg); void msgFromCore(SKMessage &msg);
//void httpResponseFinished(QNetworkReply * reply);
signals: signals:
void putMessage(SKMessage &msg); 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