Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
1dee971812 | |||
2336452447 | |||
3bdf55073a | |||
6e2fbe40fd | |||
761d7f28a8 |
10 changed files with 419 additions and 318 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>
|
|
45
main.cpp
45
main.cpp
|
@ -1,52 +1,15 @@
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QWidget>
|
#include "player_gui.h"
|
||||||
#include <QFrame>
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QGridLayout>
|
|
||||||
#include <QSizePolicy>
|
|
||||||
#include <QMenuBar>
|
|
||||||
#include <QMenu>
|
|
||||||
|
|
||||||
#include "player.h"
|
// """ Version 0.11 """
|
||||||
|
|
||||||
// """ Version 0.8 """
|
|
||||||
|
|
||||||
//using namespace std;
|
//using namespace std;
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
QWidget window;
|
player_gui w;
|
||||||
window.setGeometry(20,50,1270,576);
|
w.show();
|
||||||
|
|
||||||
QMenuBar mBar;
|
|
||||||
QMenu fileMenu;
|
|
||||||
fileMenu.addMenu("Test");
|
|
||||||
mBar.addMenu(&fileMenu);
|
|
||||||
|
|
||||||
QFrame videoWidget;
|
|
||||||
Player player(&videoWidget);
|
|
||||||
|
|
||||||
QListWidget liste;
|
|
||||||
for(int x=1;x<=player.get_Sender();x++){
|
|
||||||
liste.addItem(player.get_Name(x));
|
|
||||||
}
|
|
||||||
QObject::connect(&liste, SIGNAL(itemClicked(QListWidgetItem*)), &player, SLOT(play(QListWidgetItem*)));
|
|
||||||
|
|
||||||
QSizePolicy sp=liste.sizePolicy();
|
|
||||||
sp.setHorizontalPolicy(QSizePolicy::Fixed);
|
|
||||||
liste.setSizePolicy(sp);
|
|
||||||
|
|
||||||
QGridLayout gridLayout;
|
|
||||||
gridLayout.addWidget(&videoWidget, 0, 0);
|
|
||||||
gridLayout.addWidget(&liste, 0, 1);
|
|
||||||
window.setLayout(&gridLayout);
|
|
||||||
|
|
||||||
window.show();
|
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
141
player.cpp
141
player.cpp
|
@ -1,141 +0,0 @@
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <curl/curl.h>
|
|
||||||
#include <vlc/vlc.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
#include <QFrame>
|
|
||||||
|
|
||||||
#include "player.h"
|
|
||||||
|
|
||||||
Player::Player(QFrame *video){
|
|
||||||
this->videoWidget = video;
|
|
||||||
std::cout << "starte..." << std::endl;
|
|
||||||
|
|
||||||
this->sender_holen();
|
|
||||||
this->sender_laden();
|
|
||||||
//this->sender_ausgeben();
|
|
||||||
|
|
||||||
// Play init
|
|
||||||
/* Load the VLC engine */
|
|
||||||
inst = libvlc_new (0, NULL);
|
|
||||||
}
|
|
||||||
Player::~Player(){
|
|
||||||
if(mp){
|
|
||||||
/* Stop playing */
|
|
||||||
libvlc_media_player_stop (mp);
|
|
||||||
/* Free the media_player */
|
|
||||||
libvlc_media_player_release (mp);
|
|
||||||
libvlc_release (inst);
|
|
||||||
}
|
|
||||||
std::cout << "beende..." << std::endl;
|
|
||||||
}
|
|
||||||
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){
|
|
||||||
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");
|
|
||||||
file = fopen("channels.m3u", "wb");
|
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, this->write_data);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
|
|
||||||
res = curl_easy_perform(curl);
|
|
||||||
if(res != CURLE_OK)
|
|
||||||
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 x=0;
|
|
||||||
this->Sender=1;
|
|
||||||
QFile file("channels.m3u");
|
|
||||||
if(file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
|
||||||
while (!file.atEnd()){
|
|
||||||
QByteArray line = file.readLine();
|
|
||||||
if(line.toStdString()=="#EXTM3U\n") // erste Zeile überspringen
|
|
||||||
continue;
|
|
||||||
if(line.toStdString()=="\n") // lezte Zeile überspringen
|
|
||||||
break;
|
|
||||||
QString string = line;
|
|
||||||
string.replace(QString("#EXTINF:-1,"), QString(""));
|
|
||||||
string.replace(QString("\n"), QString("")); // Zeilenede entfernen
|
|
||||||
if(++x%2){
|
|
||||||
std::cout << this->Sender << " Name: " << string.toStdString() << std::endl;
|
|
||||||
this->Name[this->Sender]=string;
|
|
||||||
} else {
|
|
||||||
std::cout << this->Sender <<" Url: " << string.toStdString() << std::endl;
|
|
||||||
this->URL[this->Sender++]=string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Sender--; //Senderkorrektur
|
|
||||||
} else {
|
|
||||||
std::cout << "Fehler channels.m3u" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int Player::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){
|
|
||||||
|
|
||||||
if (!item)
|
|
||||||
return 1;
|
|
||||||
std::cout << "Sender: " << item->text().toStdString() << std::endl;
|
|
||||||
|
|
||||||
int x=1;
|
|
||||||
|
|
||||||
for(;x<=this->Sender;x++){
|
|
||||||
if(item->text()==Name[x]){
|
|
||||||
std::cout << "Name: " << Name[x].toStdString() << " URL: " << URL[x].toStdString() << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Stop playing */
|
|
||||||
if(mp)
|
|
||||||
libvlc_media_player_stop (mp);
|
|
||||||
|
|
||||||
|
|
||||||
QByteArray bla = URL[x].toLatin1();
|
|
||||||
const char *url = bla.data();
|
|
||||||
|
|
||||||
/* Create a new item */
|
|
||||||
m = libvlc_media_new_location (inst, url);
|
|
||||||
/* Create a media player playing environement */
|
|
||||||
mp = libvlc_media_player_new_from_media (m);
|
|
||||||
/* No need to keep the media now */
|
|
||||||
libvlc_media_release (m);
|
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) // Windows
|
|
||||||
libvlc_media_player_set_hwnd(mp, (void *)videoWidget->winId()); // hwnd
|
|
||||||
#elif defined(Q_OS_MAC) // Mac
|
|
||||||
libvlc_media_player_set_nsobject(mp, (void *)videoWidget->winId()); // view
|
|
||||||
#else //Linux
|
|
||||||
libvlc_media_player_set_xwindow (mp, (void *)videoWidget->winId()); // xid
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::cout << "play..." << std::endl;
|
|
||||||
/* play the media_player */
|
|
||||||
libvlc_media_player_play (mp);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
38
player.h
38
player.h
|
@ -1,38 +0,0 @@
|
||||||
#ifndef PLAYER_H
|
|
||||||
#define PLAYER_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QFrame>
|
|
||||||
#include <QListWidget>
|
|
||||||
#include <vlc/vlc.h>
|
|
||||||
|
|
||||||
class Player : public QObject {
|
|
||||||
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]; }
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
int play(QListWidgetItem *item);
|
|
||||||
|
|
||||||
private:
|
|
||||||
int val;
|
|
||||||
static size_t write_data(void*, size_t, size_t , void*);
|
|
||||||
int sender_holen(void);
|
|
||||||
int sender_laden(void);
|
|
||||||
int sender_ausgeben(void);
|
|
||||||
int Sender;
|
|
||||||
QString Name[10000];
|
|
||||||
QString URL[10000];
|
|
||||||
QFrame *videoWidget;
|
|
||||||
libvlc_instance_t * inst;
|
|
||||||
libvlc_media_player_t *mp=0;
|
|
||||||
libvlc_media_t *m;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // PLAYER_H
|
|
226
player_gui.cpp
Normal file
226
player_gui.cpp
Normal file
|
@ -0,0 +1,226 @@
|
||||||
|
#include "player_gui.h"
|
||||||
|
#include "ui_player_gui.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#include <vlc/vlc.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QtNetwork>
|
||||||
|
|
||||||
|
player_gui::player_gui(QWidget *parent) :
|
||||||
|
QMainWindow(parent),
|
||||||
|
ui(new Ui::player_gui){
|
||||||
|
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
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_gui::~player_gui(){
|
||||||
|
if(mp){
|
||||||
|
/* Stop playing */
|
||||||
|
libvlc_media_player_stop (mp);
|
||||||
|
/* Free the media_player */
|
||||||
|
libvlc_media_player_release (mp);
|
||||||
|
libvlc_release (inst);
|
||||||
|
}
|
||||||
|
std::cout << "beende..." << std::endl;
|
||||||
|
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
void player_gui::on_actionBeenden_triggered(){
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
void player_gui::set_ip(void){
|
||||||
|
QFile file("vlc-vdr.ini");
|
||||||
|
if(file.open(QIODevice::ReadWrite | QIODevice::Text)){
|
||||||
|
std::cout << " oeffnen erfolgreich..." << std::endl;
|
||||||
|
QByteArray line = file.readLine();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
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(this, "IP-Adresse", "IP-Adresse(127.0.0.1):Port(3000)",
|
||||||
|
QLineEdit::Normal, ip, &ok);
|
||||||
|
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;
|
||||||
|
ui->statusbar->showMessage("IP-Adresse setzen... gesetzt.", 0);
|
||||||
|
this->sender_holen();
|
||||||
|
this->sender_laden();
|
||||||
|
this->on_lineEdit_textChanged("");
|
||||||
|
}
|
||||||
|
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_gui::sender_holen(void){
|
||||||
|
|
||||||
|
manager = new QNetworkAccessManager();
|
||||||
|
|
||||||
|
QString url = "http://" + ip + "/channels.m3u";
|
||||||
|
QNetworkRequest request(url);
|
||||||
|
QNetworkReply *reply = manager->get(request);
|
||||||
|
|
||||||
|
connect(reply, &QNetworkReply::finished, [=]() {
|
||||||
|
if(reply->error() == QNetworkReply::NoError)
|
||||||
|
{
|
||||||
|
QByteArray response = reply->readAll();
|
||||||
|
std::string Daten = response.toStdString();
|
||||||
|
std::cout << Daten << std::endl;
|
||||||
|
// do something with the data...
|
||||||
|
FILE *file = fopen("channels.m3u", "wb");
|
||||||
|
if (file!=NULL)
|
||||||
|
{
|
||||||
|
std::fputs(response,file);
|
||||||
|
}
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
else // handle error
|
||||||
|
{
|
||||||
|
ui->statusbar->showMessage(reply->errorString().toUtf8().constData());
|
||||||
|
std::cout << reply->errorString().toUtf8().constData() << std::endl;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int player_gui::sender_laden(void){
|
||||||
|
int x=0;
|
||||||
|
this->Sender=1;
|
||||||
|
QFile file("channels.m3u");
|
||||||
|
if(file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||||
|
while (!file.atEnd()){
|
||||||
|
QByteArray line = file.readLine();
|
||||||
|
if(line.toStdString()=="#EXTM3U\n") // erste Zeile überspringen
|
||||||
|
continue;
|
||||||
|
if(line.toStdString()=="\n") // lezte Zeile überspringen
|
||||||
|
break;
|
||||||
|
QString string = line;
|
||||||
|
string.replace(QString("#EXTINF:-1,"), QString(""));
|
||||||
|
string.replace(QString("\n"), QString("")); // Zeilenede entfernen
|
||||||
|
if(++x%2){
|
||||||
|
std::cout << this->Sender << " Name: " << string.toStdString() << std::endl;
|
||||||
|
this->Name[this->Sender]=string;
|
||||||
|
} else {
|
||||||
|
std::cout << this->Sender <<" Url: " << string.toStdString() << std::endl;
|
||||||
|
this->URL[this->Sender++]=string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Sender--; //Senderkorrektur
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
std::cout << "Fehler channels.m3u" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
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++){
|
||||||
|
this->Name_tmp = this->Name[x].toLower();
|
||||||
|
if(this->Name_tmp.contains(arg1.toLower())){
|
||||||
|
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;
|
||||||
|
std::cout << "Sender: " << item->text().toStdString() << std::endl;
|
||||||
|
|
||||||
|
int x=1;
|
||||||
|
|
||||||
|
for(;x<=this->Sender;x++){
|
||||||
|
if(item->text()==Name[x]){
|
||||||
|
std::cout << "Name: " << Name[x].toStdString() << " URL: " << URL[x].toStdString() << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui->statusbar->showMessage(Name[x]+" - "+URL[x], 0);
|
||||||
|
/* Stop playing */
|
||||||
|
if(mp)
|
||||||
|
libvlc_media_player_stop (mp);
|
||||||
|
|
||||||
|
QByteArray bla = URL[x].toLatin1();
|
||||||
|
const char *url = bla.data();
|
||||||
|
|
||||||
|
/* Create a new item */
|
||||||
|
m = libvlc_media_new_location (inst, url);
|
||||||
|
/* Create a media player playing environement */
|
||||||
|
mp = libvlc_media_player_new_from_media (m);
|
||||||
|
/* No need to keep the media now */
|
||||||
|
libvlc_media_release (m);
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN) // Windows
|
||||||
|
libvlc_media_player_set_hwnd(mp, (void *)ui->videoWidget->winId()); // hwnd
|
||||||
|
#elif defined(Q_OS_MAC) // Mac
|
||||||
|
libvlc_media_player_set_nsobject(mp, (void *)ui->videoWidget->winId()); // view
|
||||||
|
#else //Linux
|
||||||
|
int windid = ui->videoWidget->winId();
|
||||||
|
libvlc_media_player_set_xwindow (mp, windid); // xid
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::cout << "play..." << std::endl;
|
||||||
|
/* play the media_player */
|
||||||
|
libvlc_media_player_play (mp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
50
player_gui.h
Normal file
50
player_gui.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#ifndef PLAYER_GUI_H
|
||||||
|
#define PLAYER_GUI_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QtNetwork>
|
||||||
|
#include <vlc/vlc.h>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class player_gui;
|
||||||
|
}
|
||||||
|
|
||||||
|
class player_gui : public QMainWindow{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit player_gui(QWidget *parent = 0);
|
||||||
|
~player_gui();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_actionBeenden_triggered();
|
||||||
|
void on_actionIP_Adresse_triggered();
|
||||||
|
void on_lineEdit_textChanged(const QString &arg1);
|
||||||
|
int play(QListWidgetItem *item);
|
||||||
|
|
||||||
|
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);
|
||||||
|
int sender_ausgeben(void);
|
||||||
|
int Sender;
|
||||||
|
QString Name[10000];
|
||||||
|
QString Name_tmp;
|
||||||
|
QString URL[10000];
|
||||||
|
QString ip;
|
||||||
|
QNetworkAccessManager *manager;
|
||||||
|
QFrame *videoWidget;
|
||||||
|
libvlc_instance_t * inst;
|
||||||
|
libvlc_media_player_t *mp=0;
|
||||||
|
libvlc_media_t *m;
|
||||||
|
};
|
||||||
|
|
||||||
|
#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>1160</width>
|
||||||
|
<height>20</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>
|
32
vlc-vdr.pro
32
vlc-vdr.pro
|
@ -1,16 +1,30 @@
|
||||||
|
QT += \
|
||||||
|
core \
|
||||||
|
gui \
|
||||||
|
widgets \
|
||||||
|
network
|
||||||
|
|
||||||
QT += core gui
|
QMAKE_CFLAGS_RELEASE += -Os -momit-leaf-frame-pointer
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4) : QT += widgets
|
QMAKE_LFLAGS += -static -static-libgcc
|
||||||
|
|
||||||
SOURCES += \
|
CONFIG += \
|
||||||
main.cpp \
|
c++11 \
|
||||||
player.cpp
|
static
|
||||||
|
|
||||||
LIBS += -lcurl -llibvlc
|
DEFINES += \
|
||||||
DEFINES += CURL_STATICLIB VLC_STATICLIB
|
VLC_STATICLIB \
|
||||||
|
QT_STATIC_BUILD
|
||||||
|
|
||||||
HEADERS += \
|
LIBS += \
|
||||||
player.h
|
-lvlc.dll
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
main.cpp \
|
||||||
|
player_gui.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
player_gui.h
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
player_gui.ui
|
||||||
|
|
Loading…
Add table
Reference in a new issue