Skip to content

Commit

Permalink
comet testing
Browse files Browse the repository at this point in the history
  • Loading branch information
RJ committed Jan 6, 2010
1 parent ab7dd14 commit 0c19b17
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 17 deletions.
45 changes: 39 additions & 6 deletions mainwindow.cpp
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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()
Expand All @@ -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;
Expand All @@ -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()));
Expand Down
10 changes: 8 additions & 2 deletions mainwindow.h
Expand Up @@ -11,6 +11,7 @@
#include <QPushButton>
#include <QWebView>
#include <QEvent>
#include <QMenuBar>

#include "WebkitApi.h"

Expand All @@ -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);
Expand Down Expand Up @@ -56,6 +60,8 @@ private slots:
QPushButton *playurlBtn;
QPushButton *playfileBtn;
QPushButton *reloadBtn;
QMenu * fileMenu;


void setupUi();
void play(QUrl);
Expand Down
14 changes: 8 additions & 6 deletions 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
Expand All @@ -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
17 changes: 14 additions & 3 deletions 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 = {
Expand All @@ -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 () {
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0c19b17

Please sign in to comment.