0.10
This commit is contained in:
parent
761d7f28a8
commit
6e2fbe40fd
3 changed files with 86 additions and 13 deletions
35
main.cpp
35
main.cpp
|
@ -7,14 +7,13 @@
|
|||
#include <QFile>
|
||||
#include <QGridLayout>
|
||||
#include <QSizePolicy>
|
||||
#include <QLineEdit>
|
||||
#include <QMenuBar>
|
||||
#include <QMenu>
|
||||
#include <QInputDialog>
|
||||
#include <QDir>
|
||||
|
||||
#include "player.h"
|
||||
|
||||
// """ Version 0.9 """
|
||||
// """ Version 0.10 """
|
||||
|
||||
//using namespace std;
|
||||
|
||||
|
@ -27,30 +26,44 @@ int main(int argc, char* argv[]) {
|
|||
QMenuBar menuBar(&window);
|
||||
QMenu *fileMenu;
|
||||
QMenu *workMenu;
|
||||
fileMenu=menuBar.addMenu("&Datei");
|
||||
workMenu=menuBar.addMenu("&Bearbeiten");
|
||||
fileMenu->addAction("Be&enden", exit);
|
||||
workMenu->addAction("&IP-Adresse", exit);
|
||||
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 sp=liste.sizePolicy();
|
||||
sp.setHorizontalPolicy(QSizePolicy::Fixed);
|
||||
liste.setSizePolicy(sp);
|
||||
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);
|
||||
gridLayout.addWidget(&videoWidget, 1, 0, 2, 1);
|
||||
gridLayout.addWidget(&liste, 1, 1);
|
||||
gridLayout.addWidget(&lineEdit, 2, 1);
|
||||
window.setLayout(&gridLayout);
|
||||
|
||||
window.show();
|
||||
|
|
60
player.cpp
60
player.cpp
|
@ -10,6 +10,13 @@
|
|||
|
||||
#include <QFile>
|
||||
#include <QFrame>
|
||||
#include <QInputDialog>
|
||||
#include <QDir>
|
||||
#include <QStringList>
|
||||
#include <QTextStream>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "player.h"
|
||||
|
||||
|
@ -35,18 +42,68 @@ Player::~Player(){
|
|||
}
|
||||
std::cout << "beende..." << std::endl;
|
||||
}
|
||||
int Player::set_ip(void){
|
||||
std::cout << "IP-Adresse setzen..." << std::endl;
|
||||
QFile file("vlc-vdr.ini");
|
||||
QString ip;
|
||||
if(file.open(QIODevice::ReadOnly | 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";
|
||||
}else{
|
||||
ip = string;
|
||||
}
|
||||
std::cout << ip.toStdString() << " gesetzt..." << std::endl;
|
||||
}else{
|
||||
std::cout << " oeffnen fehlgeschlagen..." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
bool ok;
|
||||
QString text = QInputDialog::getText(0, "IP-Adresse", "IP-Adresse(127.0.0.1):Port(3000)",
|
||||
QLineEdit::Normal, ip, &ok);
|
||||
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;
|
||||
}
|
||||
size_t Player::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;
|
||||
}
|
||||
}
|
||||
CURL *curl;
|
||||
FILE *file;
|
||||
CURLcode res;
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
curl = curl_easy_init();
|
||||
if(curl){
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.101.9:3000/channels.m3u");
|
||||
QString url = "http://" + ip + "/channels.m3u";
|
||||
std::string urls = url.toStdString();
|
||||
const char *cstr = urls.c_str();
|
||||
curl_easy_setopt(curl, CURLOPT_URL, cstr);
|
||||
file = fopen("channels.m3u", "wb");
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, this->write_data);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
|
||||
|
@ -84,6 +141,7 @@ int Player::sender_laden(void){
|
|||
}
|
||||
}
|
||||
Sender--; //Senderkorrektur
|
||||
file.close();
|
||||
} else {
|
||||
std::cout << "Fehler channels.m3u" << std::endl;
|
||||
return 1;
|
||||
|
|
4
player.h
4
player.h
|
@ -18,6 +18,7 @@ class Player : public QObject {
|
|||
|
||||
public slots:
|
||||
int play(QListWidgetItem *item);
|
||||
int set_ip(void);
|
||||
|
||||
private:
|
||||
int val;
|
||||
|
@ -27,7 +28,8 @@ class Player : public QObject {
|
|||
int sender_ausgeben(void);
|
||||
int Sender;
|
||||
QString Name[10000];
|
||||
QString URL[10000];
|
||||
QString URL[10000];
|
||||
QString ip;
|
||||
QFrame *videoWidget;
|
||||
libvlc_instance_t * inst;
|
||||
libvlc_media_player_t *mp=0;
|
||||
|
|
Loading…
Add table
Reference in a new issue