/
mythflashplayer.cpp
98 lines (77 loc) · 2.28 KB
/
mythflashplayer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <stdlib.h>
#include <iostream>
// qt
#include <QApplication>
#include <QEvent>
// myth
#include <mythverbose.h>
#include <mythcontext.h>
#include <libmythui/mythmainwindow.h>
#include <mythuiwebbrowser.h>
// mythbrowser
#include "webpage.h"
#include "mythflashplayer.h"
using namespace std;
MythFlashPlayer::MythFlashPlayer(MythScreenStack *parent,
QStringList &urlList)
: MythScreenType (parent, "mythflashplayer"),
m_browser(NULL), m_url(urlList[0])
{
qApp->setOverrideCursor(QCursor(Qt::BlankCursor));
}
MythFlashPlayer::~MythFlashPlayer()
{
qApp->restoreOverrideCursor();
if (m_browser)
{
m_browser->disconnect();
DeleteChild(m_browser);
m_browser = NULL;
}
}
bool MythFlashPlayer::Create(void)
{
m_browser = new MythUIWebBrowser(this, "mythflashplayer");
m_browser->SetArea(GetMythMainWindow()->GetUIScreenRect());
m_browser->Init();
m_browser->SetActive(true);
m_browser->Show();
BuildFocusList();
SetFocusWidget(m_browser);
m_url.replace("mythflash://", "http://");
VERBOSE(VB_GENERAL, QString("Opening %1").arg(m_url));
m_browser->LoadPage(QUrl::fromEncoded(m_url.toLocal8Bit()));
return true;
}
QVariant MythFlashPlayer::evaluateJavaScript(const QString& source)
{
return m_browser->evaluateJavaScript(source);
}
bool MythFlashPlayer::keyPressEvent(QKeyEvent *event)
{
QStringList actions;
bool handled = GetMythMainWindow()->TranslateKeyPress("TV Playback", event, actions);
for (int i = 0; i < actions.size() && !handled; i++)
{
QString action = actions[i];
handled = true;
if (action == "PAUSE")
evaluateJavaScript("play();");
else if (action == "SEEKFFWD")
evaluateJavaScript("seek(10);");
else if (action == "SEEKRWND")
evaluateJavaScript("seek(-10);");
else if (action == "CHANNELUP")
evaluateJavaScript("seek(60);");
else if (action == "CHANNELDOWN")
evaluateJavaScript("seek(-60);");
else
handled = false;
if (handled)
return true;
}
handled = m_browser->keyPressEvent(event);
if (!handled && MythScreenType::keyPressEvent(event))
handled = true;
return handled;
}