Skip to content

Commit

Permalink
Pause video and disconnect from chat while showing past broadcasts,
Browse files Browse the repository at this point in the history
Fix reconnection to chat.
  • Loading branch information
Aldrog committed Jul 31, 2016
1 parent e815ccf commit 1c30a5b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 18 additions & 1 deletion sailfish-ui/pages/StreamPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,24 @@ Page {
MenuItem {
text: qsTr("Past Broadcasts & Highlights")
onClicked: {
pageStack.push(Qt.resolvedUrl("ChannelPage.qml"), {channel: channel, display: channelDisplay})
var page = pageStack.push(Qt.resolvedUrl("ChannelPage.qml"), {channel: channel, display: channelDisplay})
console.log(PageStatus.Deactivating, PageNavigation.Back)
page.statusChanged.connect(function() {
if(page.status === PageStatus.Deactivating && page._navigation === PageNavigation.Back) {
mainWindow.stopAudio()
video.play()
if(!twitchChat.connected) {
twitchChat.reopenSocket()
twitchChat.join(channel)
}
}
})
mainWindow.cover = Qt.resolvedUrl("../cover/NavigationCover.qml")
video.pause()
if(audioMode)
mainWindow.playAudio()
if(twitchChat.connected)
twitchChat.disconnect()
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/ircchat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void IrcChat::join(const QString channel) {
sock->write(("PASS " + userpass + "\r\n").toStdString().c_str());
sock->write(("NICK " + username + "\r\n").toStdString().c_str());
// Join channel's chat room
sock->write(("JOIN #" + channel + "\r\n").toStdString().c_str());
qDebug() << sock->write(("JOIN #" + channel + "\r\n").toStdString().c_str());

QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(badgesReceived(QNetworkReply*)));
Expand All @@ -68,9 +68,11 @@ void IrcChat::disconnect() {
}

void IrcChat::reopenSocket() {
qDebug() << "Reopening socket";
if(sock->isOpen())
sock->close();
sock->open(QIODevice::ReadWrite);
sock->connectToHost(HOST, PORT);
if(!sock->isOpen()) {
errorOccured("Error opening socket");
}
Expand Down

0 comments on commit 1c30a5b

Please sign in to comment.