A little interface program to play dreambox webif streams
Posted: Fri Mar 22, 2013 7:16 pm
Below the source for a little program and the associated .desktop file to play webif streams (.m3u) on the Pi.
The program must be compiled and the .desktop file amended to reflect where you put the program.
The .desktop file must be put in /usr/share/applications/m3u2omxplayer (after fixing where the program executable is).
Then open file manager, right click on a file with .m3u extension, set the default program to open the file to be the compiled program(remember to tick the box at the bottom to remember the association).
Then go to your dreambox ip as per normal and click the icon to play the station.
Unfortunately omxplayer leaves the screen black - to get the full display back, click on start/logout and cancel the logout.
The program source:
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
using namespace std;
char cmd[1024];
char *getCMD(char *m3uname) {
char buf[1024];
FILE *t = fopen(m3uname, "r");
if (t) {
while(1) {
fgets(buf, sizeof(buf), t);
if (feof(t)) {
fclose(t);
break;
}
if (memcmp(buf, "http:", 5) == 0) {
sprintf(cmd, "/usr/bin/lxterminal -e /usr/bin/omxplayer %s", buf);
return(cmd);
}
}
}
return("");
}
int main (int argc, char **argv)
{
char buf[1024];
system(getCMD(argv[1]));
return 0;
}
The /usr/share/applications/m3u2omxplayer.desktop file( you put the executabel as /home/pi/m3u2omxplayer):
[Desktop Entry]
Version=1.0
Name=m3u2omxplayer media player
GenericName=Media player
Comment=Read, capture, broadcast your multimedia streams
Exec=/home/pi/m3u2omxplayer %f
TryExec=/home/pi/m3u2omxplayer
Icon=vlc
Terminal=false
Type=Application
Categories=AudioVideo;Player;Recorder;
MimeType=video/dv;video/mpeg;video/x-mpeg;video/msvideo;video/quicktime;video/x-anim;video/x-avi;video/x-ms-asf;video/x-ms-wmv;video/x-msvideo;video/x-nsv;video/x-flc;video/x-fli;video/x-flv;video/vnd.rn-realvideo;video/mp4;video/mp4v-es;video/mp2t;application/ogg;application/x-ogg;video/x-ogm+ogg;audio/x-vorbis+ogg;application/x-matroska;audio/x-matroska;video/x-matroska;video/webm;audio/webm;audio/x-mp3;audio/x-mpeg;audio/mpeg;audio/x-wav;audio/x-mpegurl;audio/x-scpls;audio/x-m4a;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;application/vnd.rn-realmedia;audio/x-real-audio;audio/x-pn-realaudio;application/x-flac;audio/x-flac;application/x-shockwave-flash;misc/ultravox;audio/vnd.rn-realaudio;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-wav;audio/x-pn-windows-acm;image/vnd.rn-realpix;audio/x-pn-realaudio-plugin;application/x-extension-mp4;audio/mp4;audio/amr;audio/amr-wb;x-content/video-vcd;x-content/video-svcd;x-content/video-dvd;x-content/audio-cdda;x-content/audio-player;application/xspf+xml;x-scheme-handler/mms;x-scheme-handler/rtmp;x-scheme-handler/rtsp;
X-KDE-Protocols=ftp,http,https,mms,rtmp,rtsp,sftp,smb
Keywords=Player;Capture;DVD;Audio;Video;Server;Broadcast;
Enjoy
The program must be compiled and the .desktop file amended to reflect where you put the program.
The .desktop file must be put in /usr/share/applications/m3u2omxplayer (after fixing where the program executable is).
Then open file manager, right click on a file with .m3u extension, set the default program to open the file to be the compiled program(remember to tick the box at the bottom to remember the association).
Then go to your dreambox ip as per normal and click the icon to play the station.
Unfortunately omxplayer leaves the screen black - to get the full display back, click on start/logout and cancel the logout.
The program source:
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
using namespace std;
char cmd[1024];
char *getCMD(char *m3uname) {
char buf[1024];
FILE *t = fopen(m3uname, "r");
if (t) {
while(1) {
fgets(buf, sizeof(buf), t);
if (feof(t)) {
fclose(t);
break;
}
if (memcmp(buf, "http:", 5) == 0) {
sprintf(cmd, "/usr/bin/lxterminal -e /usr/bin/omxplayer %s", buf);
return(cmd);
}
}
}
return("");
}
int main (int argc, char **argv)
{
char buf[1024];
system(getCMD(argv[1]));
return 0;
}
The /usr/share/applications/m3u2omxplayer.desktop file( you put the executabel as /home/pi/m3u2omxplayer):
[Desktop Entry]
Version=1.0
Name=m3u2omxplayer media player
GenericName=Media player
Comment=Read, capture, broadcast your multimedia streams
Exec=/home/pi/m3u2omxplayer %f
TryExec=/home/pi/m3u2omxplayer
Icon=vlc
Terminal=false
Type=Application
Categories=AudioVideo;Player;Recorder;
MimeType=video/dv;video/mpeg;video/x-mpeg;video/msvideo;video/quicktime;video/x-anim;video/x-avi;video/x-ms-asf;video/x-ms-wmv;video/x-msvideo;video/x-nsv;video/x-flc;video/x-fli;video/x-flv;video/vnd.rn-realvideo;video/mp4;video/mp4v-es;video/mp2t;application/ogg;application/x-ogg;video/x-ogm+ogg;audio/x-vorbis+ogg;application/x-matroska;audio/x-matroska;video/x-matroska;video/webm;audio/webm;audio/x-mp3;audio/x-mpeg;audio/mpeg;audio/x-wav;audio/x-mpegurl;audio/x-scpls;audio/x-m4a;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;application/vnd.rn-realmedia;audio/x-real-audio;audio/x-pn-realaudio;application/x-flac;audio/x-flac;application/x-shockwave-flash;misc/ultravox;audio/vnd.rn-realaudio;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-wav;audio/x-pn-windows-acm;image/vnd.rn-realpix;audio/x-pn-realaudio-plugin;application/x-extension-mp4;audio/mp4;audio/amr;audio/amr-wb;x-content/video-vcd;x-content/video-svcd;x-content/video-dvd;x-content/audio-cdda;x-content/audio-player;application/xspf+xml;x-scheme-handler/mms;x-scheme-handler/rtmp;x-scheme-handler/rtsp;
X-KDE-Protocols=ftp,http,https,mms,rtmp,rtsp,sftp,smb
Keywords=Player;Capture;DVD;Audio;Video;Server;Broadcast;
Enjoy