Skip to content
Browse files

comet testing

  • Loading branch information...
1 parent ab7dd14 commit 0c19b1730cae2062c9a796bd5c8d75e590ea8257 @RJ committed Jan 6, 2010
Showing with 69 additions and 17 deletions.
  1. +39 −6 mainwindow.cpp
  2. +8 −2 mainwindow.h
  3. +8 −6 musickit.pro
  4. +14 −3 www/player/scripts/player.js
View
45 mainwindow.cpp
@@ -8,11 +8,15 @@
#include <QGridLayout>
#include <QPushButton>
#include <QInputDialog>
-#include <QNetworkCookieJar>
-#include <QNetworkCookie>
+#include <QWebSecurityOrigin>
+#include <QMenu>
+#include <QMenuItem>
+//#include <QNetworkCookieJar>
+//#include <QNetworkCookie>
-MainWindow::MainWindow(QWidget *parent)
+
+MainWindow::MainWindow()
{
/*QXmppLogger::getLogger()->setLoggingType(QXmppLogger::FILE);
@@ -28,7 +32,7 @@ MainWindow::MainWindow(QWidget *parent)
jabber->connectToServer(server, jid, pass);
*/
- setParent(parent);
+
source = 0;
audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
mediaObject = new Phonon::MediaObject(this);
@@ -56,8 +60,20 @@ MainWindow::MainWindow(QWidget *parent)
connect(webkitApi, SIGNAL(stopRequested()), this, SLOT(stop()));
connect(audioOutput, SIGNAL(volumeChanged(qreal)), this, SLOT(volumeChanged(qreal)));
- QString url("./www/player/index.html");
+ //QString url("http://localhost:8000/");
+ QString url("file:///home/rj/src/musickit/www/player/index.html");
+ //QString url("http://ideamonk.madetokill.com/bakabot/");
+/*
+
+ webView->page()->currentFrame()->securityOrigin().addLocalScheme("http");
+ webView->page()->currentFrame()->securityOrigin().addLocalScheme("ws");
+ webView->page()->currentFrame()->securityOrigin().addLocalScheme("http:");
+ webView->page()->currentFrame()->securityOrigin().addLocalScheme("ws:");
+*/
webView->load(QUrl(url));
+
+ qDebug() << "SEC:" << webView->page()->currentFrame()->securityOrigin().host() << ":" <<
+ webView->page()->currentFrame()->securityOrigin().port();
}
MainWindow::~MainWindow()
@@ -66,11 +82,22 @@ MainWindow::~MainWindow()
void MainWindow::setupUi()
{
+ fileMenu = menuBar()->addMenu("&File");
+ QAction * exAct = new QAction("E&xit", this);
+ connect(exAct, SIGNAL(triggered()), this, SLOT(close()));
+
+ fileMenu->addAction(exAct);
+
+
+
QGridLayout *layout = new QGridLayout();
webView = new QWebView();
+
webView->setPage(new Webpage);
webView->settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls,true); // needs QT >= 4.6
+ webView->settings()->globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
+ webView->settings()->globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
// QNetworkCookieJar jar;
//QList<QNetworkCookie> cookies;
@@ -90,7 +117,13 @@ void MainWindow::setupUi()
*/
//layout->setSpacing(0);
layout->setContentsMargins(QMargins(0,0,0,0));
- setLayout(layout);
+
+ QWidget *widget = new QWidget;
+ widget->setLayout(layout);
+ setCentralWidget(widget);
+
+
+ //setLayout(layout);
show();
connect(playurlBtn, SIGNAL(clicked()), this, SLOT(on_streambutton_clicked()));
View
10 mainwindow.h
@@ -11,6 +11,7 @@
#include <QPushButton>
#include <QWebView>
#include <QEvent>
+#include <QMenuBar>
#include "WebkitApi.h"
@@ -22,12 +23,15 @@ class Webpage : public QWebPage
}
};
-class MainWindow : QWidget {
+class MainWindow : QMainWindow {
Q_OBJECT
public:
- MainWindow(QWidget *parent = 0);
+ MainWindow();
~MainWindow();
friend class WebkitApi;
+ QSize sizeHint() const {
+ return QSize(800, 480);
+ }
protected:
void changeEvent(QEvent *e);
@@ -56,6 +60,8 @@ private slots:
QPushButton *playurlBtn;
QPushButton *playfileBtn;
QPushButton *reloadBtn;
+ QMenu * fileMenu;
+
void setupUi();
void play(QUrl);
View
14 musickit.pro
@@ -1,12 +1,7 @@
# -------------------------------------------------
# Project created by QtCreator 2009-12-22T13:28:55
# -------------------------------------------------
-QT += network \
- script \
- scripttools \
- webkit \
- xml \
- phonon
+QT += webkit phonon
TARGET = musickit
TEMPLATE = app
@@ -18,5 +13,12 @@ HEADERS += mainwindow.h \
+#QMAKE_LFLAGS += -static # to try and build everything (not just qt) statically
+
+
+#CONFIG += static warn_off # for static qt
+
+#LIBS += -lgloox
+
# explicitly link to winsock (not sure why this is needed)
#windows:LIBS += -lws2_32
View
17 www/player/scripts/player.js
@@ -1,3 +1,7 @@
+//if ("WebSocket" in window) alert('yes'); else alert('no');
+
+function myalert(json) { alert( JSON.stringify(json) ); }
+
Player = function(){}
Player.prototype = {
@@ -10,6 +14,7 @@ Player.prototype = {
Playdar.USE_STATUS_BAR=false;
Playdar.USE_SCROBBLER = false;
Playdar.MAX_POLLS = 20;
+ Playdar.USE_COMET = true;
Playdar.setupClient({
onAuth: function () {
@@ -87,6 +92,11 @@ Player.prototype = {
p.play({'artist':'Mokele', 'track':'Hiding in your insides', 'url':'http://www.playdar.org/hiding.mp3'}, 'http://www.playdar.org/hiding.mp3');
});
+ // toggle unplayable visibility
+ $('#rand').click(function(){
+ $('tr.unplayable').toggleClass('hidden');
+ });
+
this.playlists = {};
// Wire up events from musickit container:
@@ -208,8 +218,9 @@ $(document).ready(function(){
p.go();
var req = new XMLHttpRequest();
- req.open("GET", "http://ws.audioscrobbler.com/1.0/tag/metal/toptracks.xspf", false);
- //req.open("GET", "toptracks.xspf", false);
+// req.open("GET", "http://ws.audioscrobbler.com/1.0/tag/metal/toptracks.xspf", false);
+ //req.open("GET", "http://localhost:60210/static/toptracks.xspf", false);
+ req.open("GET", "file:///home/rj/src/playdar-core/priv/www/static/toptracks.xspf", false);
req.send("");
var doc = req.responseXML;//.documentElement;
var jspf = XSPF.toJSPF(doc);
@@ -363,7 +374,7 @@ Playlist.prototype = {
})
.find("td.track").text(trk.track).end()
.find("td.artist").text(trk.artist).end()
- .find("td.duration").text(Playdar.Util.mmss(trk.duration)).end()
+ .find("td.duration").text(Playdar.Util.mmss(parseInt(trk.duration))).end()
.find("td.status").text("Searching").end()
.find("td.alt").text('').end()
.appendTo(this.list);

0 comments on commit 0c19b17

Please sign in to comment.
Something went wrong with that request. Please try again.