0.11
This commit is contained in:
parent
6e2fbe40fd
commit
3bdf55073a
8 changed files with 206 additions and 206 deletions
14
gui.cpp
14
gui.cpp
|
@ -1,14 +0,0 @@
|
|||
#include "gui.h"
|
||||
#include "ui_gui.h"
|
||||
|
||||
GUI::GUI(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::GUI)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
GUI::~GUI()
|
||||
{
|
||||
delete ui;
|
||||
}
|
22
gui.h
22
gui.h
|
@ -1,22 +0,0 @@
|
|||
#ifndef GUI_H
|
||||
#define GUI_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class GUI;
|
||||
}
|
||||
|
||||
class GUI : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GUI(QWidget *parent = 0);
|
||||
~GUI();
|
||||
|
||||
//private:
|
||||
Ui::GUI *ui;
|
||||
};
|
||||
|
||||
#endif // GUI_H
|
53
gui.ui
53
gui.ui
|
@ -1,53 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GUI</class>
|
||||
<widget class="QWidget" name="GUI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>884</width>
|
||||
<height>562</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="videoWidget">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QListWidget" name="liste">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>210</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
65
main.cpp
65
main.cpp
|
@ -1,72 +1,15 @@
|
|||
#include <iostream>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QFrame>
|
||||
#include <QHBoxLayout>
|
||||
#include <QFile>
|
||||
#include <QGridLayout>
|
||||
#include <QSizePolicy>
|
||||
#include <QLineEdit>
|
||||
#include <QMenuBar>
|
||||
#include <QMenu>
|
||||
#include "player_gui.h"
|
||||
|
||||
#include "player.h"
|
||||
|
||||
// """ Version 0.10 """
|
||||
// """ Version 0.11 """
|
||||
|
||||
//using namespace std;
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QWidget window;
|
||||
window.setGeometry(20,50,1270,590);
|
||||
|
||||
QMenuBar menuBar(&window);
|
||||
QMenu *fileMenu;
|
||||
QMenu *workMenu;
|
||||
fileMenu=menuBar.addMenu("&Programm");
|
||||
workMenu=menuBar.addMenu("&Einstellen");
|
||||
fileMenu->addAction("Be&enden", app.exit);
|
||||
QAction *ipAction=workMenu->addAction("&IP-Adresse");
|
||||
|
||||
QFrame videoWidget;
|
||||
Player player(&videoWidget);
|
||||
|
||||
QSizePolicy vw=videoWidget.sizePolicy();
|
||||
vw.setHorizontalPolicy(QSizePolicy::Expanding);
|
||||
videoWidget.setSizePolicy(vw);
|
||||
|
||||
QListWidget liste;
|
||||
for(int x=1;x<=player.get_Sender();x++){
|
||||
liste.addItem(player.get_Name(x));
|
||||
}
|
||||
//Sender anklicken
|
||||
QObject::connect(&liste, SIGNAL(itemClicked(QListWidgetItem*)), &player, SLOT(play(QListWidgetItem*)));
|
||||
//IP einstellen
|
||||
QObject::connect(ipAction, SIGNAL(triggered()), &player, SLOT(set_ip()));
|
||||
|
||||
QSizePolicy li=liste.sizePolicy();
|
||||
li.setHorizontalPolicy(QSizePolicy::Fixed);
|
||||
liste.setSizePolicy(li);
|
||||
|
||||
QLineEdit lineEdit;
|
||||
|
||||
QSizePolicy le=lineEdit.sizePolicy();
|
||||
le.setHorizontalPolicy(QSizePolicy::Fixed);
|
||||
lineEdit.setSizePolicy(le);
|
||||
|
||||
QGridLayout gridLayout;
|
||||
gridLayout.setMargin(0);
|
||||
gridLayout.setSpacing(0);
|
||||
gridLayout.addWidget(&menuBar, 0, 0, 1, 0);
|
||||
gridLayout.addWidget(&videoWidget, 1, 0, 2, 1);
|
||||
gridLayout.addWidget(&liste, 1, 1);
|
||||
gridLayout.addWidget(&lineEdit, 2, 1);
|
||||
window.setLayout(&gridLayout);
|
||||
|
||||
window.show();
|
||||
player_gui w;
|
||||
w.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#include "player_gui.h"
|
||||
#include "ui_player_gui.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <vlc/vlc.h>
|
||||
|
@ -14,25 +18,28 @@
|
|||
#include <QDir>
|
||||
#include <QStringList>
|
||||
#include <QTextStream>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "player.h"
|
||||
player_gui::player_gui(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::player_gui){
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
Player::Player(QFrame *video){
|
||||
this->videoWidget = video;
|
||||
std::cout << "starte..." << std::endl;
|
||||
ui->statusbar->showMessage("starte...", 0);
|
||||
|
||||
this->set_ip();
|
||||
this->sender_holen();
|
||||
this->sender_laden();
|
||||
//this->sender_ausgeben();
|
||||
this->on_lineEdit_textChanged("");
|
||||
|
||||
// Play init
|
||||
/* Load the VLC engine */
|
||||
inst = libvlc_new (0, NULL);
|
||||
}
|
||||
Player::~Player(){
|
||||
player_gui::~player_gui(){
|
||||
if(mp){
|
||||
/* Stop playing */
|
||||
libvlc_media_player_stop (mp);
|
||||
|
@ -41,59 +48,58 @@ Player::~Player(){
|
|||
libvlc_release (inst);
|
||||
}
|
||||
std::cout << "beende..." << std::endl;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
int Player::set_ip(void){
|
||||
std::cout << "IP-Adresse setzen..." << std::endl;
|
||||
void player_gui::on_actionBeenden_triggered(){
|
||||
|
||||
exit(0);
|
||||
}
|
||||
void player_gui::set_ip(void){
|
||||
QFile file("vlc-vdr.ini");
|
||||
QString ip;
|
||||
if(file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||
if(file.open(QIODevice::ReadWrite | QIODevice::Text)){
|
||||
std::cout << " oeffnen erfolgreich..." << std::endl;
|
||||
QByteArray line = file.readLine();
|
||||
file.close();
|
||||
QString string = line;
|
||||
if(string==""){
|
||||
ip = "127.0.0.1:3000";
|
||||
QTextStream output(&file);
|
||||
output << ip;
|
||||
}else{
|
||||
ip = string;
|
||||
}
|
||||
std::cout << ip.toStdString() << " gesetzt..." << std::endl;
|
||||
}else{
|
||||
std::cout << " oeffnen fehlgeschlagen..." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
void player_gui::on_actionIP_Adresse_triggered() {
|
||||
this->set_ip();
|
||||
QFile file("vlc-vdr.ini");
|
||||
std::cout << "IP-Adresse setzen..." << std::endl;
|
||||
ui->statusbar->showMessage("IP-Adresse setzen...", 0);
|
||||
bool ok;
|
||||
QString text = QInputDialog::getText(0, "IP-Adresse", "IP-Adresse(127.0.0.1):Port(3000)",
|
||||
QString text = QInputDialog::getText(this, "IP-Adresse", "IP-Adresse(127.0.0.1):Port(3000)",
|
||||
QLineEdit::Normal, ip, &ok);
|
||||
ip = text;
|
||||
if(text!="")
|
||||
ip = text;
|
||||
if(file.open(QIODevice::WriteOnly | QIODevice::Text)){
|
||||
QTextStream output(&file);
|
||||
output << ip;
|
||||
file.close();
|
||||
}
|
||||
std::cout << text.toStdString() << " gesetzt." << std::endl;
|
||||
|
||||
int ret = QMessageBox::warning(0, "Beenden?", "Programm neu starten!", QMessageBox::Yes);
|
||||
|
||||
return 0;
|
||||
ui->statusbar->showMessage("IP-Adresse setzen... gesetzt.", 0);
|
||||
this->sender_holen();
|
||||
this->sender_laden();
|
||||
this->on_lineEdit_textChanged("");
|
||||
}
|
||||
size_t Player::write_data(void *ptr, size_t size, size_t nmemb, void *stream){
|
||||
size_t player_gui::write_data(void *ptr, size_t size, size_t nmemb, void *stream){
|
||||
size_t written = fwrite(ptr, size, nmemb, (FILE *)stream);
|
||||
return written;
|
||||
}
|
||||
int Player::sender_holen(void){
|
||||
QFile ifile("vlc-vdr.ini");
|
||||
QString ip;
|
||||
if(ifile.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||
std::cout << " oeffnen erfolgreich..." << std::endl;
|
||||
QByteArray line = ifile.readLine();
|
||||
ifile.close();
|
||||
QString string = line;
|
||||
if(string==""){
|
||||
ip = "127.0.0.1:3000";
|
||||
}else{
|
||||
ip = string;
|
||||
}
|
||||
}
|
||||
int player_gui::sender_holen(void){
|
||||
CURL *curl;
|
||||
FILE *file;
|
||||
CURLcode res;
|
||||
|
@ -112,13 +118,12 @@ int Player::sender_holen(void){
|
|||
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
|
||||
else
|
||||
std::cout << "Sender holen und in channels.m3u speichern..." << std::endl;
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
int Player::sender_laden(void){
|
||||
int player_gui::sender_laden(void){
|
||||
int x=0;
|
||||
this->Sender=1;
|
||||
QFile file("channels.m3u");
|
||||
|
@ -148,13 +153,27 @@ int Player::sender_laden(void){
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
int Player::sender_ausgeben(void){
|
||||
int player_gui::sender_ausgeben(void){
|
||||
for(int x=1;x<=this->Sender;x++){
|
||||
std::cout << x << ". " << this->Name[x].toStdString() << "," << this->URL[x].toStdString() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int Player::play(QListWidgetItem *item){
|
||||
void player_gui::on_lineEdit_textChanged(const QString &arg1){
|
||||
std::cout << "suchen" << std::endl;
|
||||
ui->listWidget->clear();
|
||||
for(int x=1;x<=this->Sender;x++){
|
||||
if(this->Name[x].contains(arg1)){
|
||||
ui->listWidget->addItem(this->Name[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
void player_gui::on_listWidget_itemClicked(QListWidgetItem *item)
|
||||
{
|
||||
std::cout << item->text().toStdString() << std::endl;
|
||||
this->play(item);
|
||||
}
|
||||
int player_gui::play(QListWidgetItem *item){
|
||||
|
||||
if (!item)
|
||||
return 1;
|
||||
|
@ -168,6 +187,7 @@ int Player::play(QListWidgetItem *item){
|
|||
break;
|
||||
}
|
||||
}
|
||||
ui->statusbar->showMessage(Name[x]+" - "+URL[x], 0);
|
||||
/* Stop playing */
|
||||
if(mp)
|
||||
libvlc_media_player_stop (mp);
|
||||
|
@ -183,11 +203,11 @@ int Player::play(QListWidgetItem *item){
|
|||
libvlc_media_release (m);
|
||||
|
||||
#if defined(Q_OS_WIN) // Windows
|
||||
libvlc_media_player_set_hwnd(mp, (void *)videoWidget->winId()); // hwnd
|
||||
libvlc_media_player_set_hwnd(mp, (void *)ui->videoWidget->winId()); // hwnd
|
||||
#elif defined(Q_OS_MAC) // Mac
|
||||
libvlc_media_player_set_nsobject(mp, (void *)videoWidget->winId()); // view
|
||||
libvlc_media_player_set_nsobject(mp, (void *)ui->videoWidget->winId()); // view
|
||||
#else //Linux
|
||||
int windid = videoWidget->winId();
|
||||
int windid = ui->videoWidget->winId();
|
||||
libvlc_media_player_set_xwindow (mp, windid); // xid
|
||||
#endif
|
||||
|
|
@ -1,27 +1,35 @@
|
|||
#ifndef PLAYER_H
|
||||
#define PLAYER_H
|
||||
#ifndef PLAYER_GUI_H
|
||||
#define PLAYER_GUI_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QObject>
|
||||
#include <QFile>
|
||||
#include <QFrame>
|
||||
#include <QListWidget>
|
||||
#include <vlc/vlc.h>
|
||||
|
||||
class Player : public QObject {
|
||||
namespace Ui {
|
||||
class player_gui;
|
||||
}
|
||||
|
||||
class player_gui : public QMainWindow{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Player(QFrame*);
|
||||
~Player();
|
||||
int get_Sender() { return this->Sender; }
|
||||
QString get_Name(int x) { return this->Name[x]; }
|
||||
QString get_URL(int x) { return this->URL[x]; }
|
||||
explicit player_gui(QWidget *parent = 0);
|
||||
~player_gui();
|
||||
|
||||
public slots:
|
||||
private slots:
|
||||
void on_actionBeenden_triggered();
|
||||
void on_actionIP_Adresse_triggered();
|
||||
void on_lineEdit_textChanged(const QString &arg1);
|
||||
int play(QListWidgetItem *item);
|
||||
int set_ip(void);
|
||||
|
||||
private:
|
||||
int val;
|
||||
void on_listWidget_itemClicked(QListWidgetItem *item);
|
||||
|
||||
private:
|
||||
Ui::player_gui *ui;
|
||||
void set_ip(void);
|
||||
static size_t write_data(void*, size_t, size_t , void*);
|
||||
int sender_holen(void);
|
||||
int sender_laden(void);
|
||||
|
@ -34,7 +42,6 @@ class Player : public QObject {
|
|||
libvlc_instance_t * inst;
|
||||
libvlc_media_player_t *mp=0;
|
||||
libvlc_media_t *m;
|
||||
|
||||
};
|
||||
|
||||
#endif // PLAYER_H
|
||||
#endif // PLAYER_GUI_H
|
116
player_gui.ui
Normal file
116
player_gui.ui
Normal file
|
@ -0,0 +1,116 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>player_gui</class>
|
||||
<widget class="QMainWindow" name="player_gui">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1160</width>
|
||||
<height>620</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>vlc-vdr</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="videoWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1210</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuProgramm">
|
||||
<property name="title">
|
||||
<string>Programm</string>
|
||||
</property>
|
||||
<addaction name="actionBeenden"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuEinstellen">
|
||||
<property name="title">
|
||||
<string>Einstellen</string>
|
||||
</property>
|
||||
<addaction name="actionIP_Adresse"/>
|
||||
</widget>
|
||||
<addaction name="menuProgramm"/>
|
||||
<addaction name="menuEinstellen"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionBeenden">
|
||||
<property name="text">
|
||||
<string>Beenden</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionIP_Adresse">
|
||||
<property name="text">
|
||||
<string>IP-Adresse</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -5,12 +5,15 @@ greaterThan(QT_MAJOR_VERSION, 4) : QT += widgets
|
|||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
player.cpp
|
||||
player_gui.cpp
|
||||
|
||||
LIBS += -lcurl -lvlc
|
||||
DEFINES += CURL_STATICLIB VLC_STATICLIB
|
||||
|
||||
HEADERS += \
|
||||
player.h
|
||||
player_gui.h
|
||||
|
||||
#CONFIG+= static
|
||||
|
||||
FORMS += \
|
||||
player_gui.ui
|
||||
|
|
Loading…
Add table
Reference in a new issue