Skip to content

Commit

Permalink
Streaming link added to schedule pages. Small corrections.
Browse files Browse the repository at this point in the history
  • Loading branch information
REELcoder authored and kfb77 committed Aug 9, 2020
1 parent 309d9df commit e7fd453
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pages/pageelems.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int update_status(1);
<%args>
tChannelID channelId;
</%args>
<%cpp> if (LiveSetup().GetUseStreamdev() && LiveFeatures<features::streamdev_server>().Loaded()) { </%cpp><a href="playlist.m3u?channel=<$ channelId $>"><img src="<$ LiveSetup().GetThemedLink("img", "stream_button.png") $>" alt="" <& tooltip.hint text=(tr("Stream this channel into media player.")) &>></img></a><%cpp> } </%cpp>
<%cpp> if (LiveSetup().GetUseStreamdev() && LiveFeatures<features::streamdev_server>().Loaded()) { </%cpp><a href="stream.html?channelid=<$ channelId $>"><img src="<$ LiveSetup().GetThemedLink("img", "stream_button.png") $>" alt="" <& tooltip.hint text=(tr("Stream this channel into browser.")) &>></img></a><%cpp> } </%cpp>
</%def>

<# ---------------------------------------------------------------------- #>
Expand Down
4 changes: 4 additions & 0 deletions pages/schedule.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,8 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
<& pageelems.m3u_playlist_channel channelId=(Channel->GetChannelID()) &>
</span>
</form>
<span class="sep">|</span>
<a href="schedule.html?channel=<$ std::max(0, ((int)Channel->Number() - 1)) $>">« Prev</a>
<span class="sep">|</span>
<a href="schedule.html?channel=<$ (Channel->Number() + 1) $>">Next »</a>
</%def>
44 changes: 28 additions & 16 deletions pages/stream.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ using namespace vdrlive;

</%pre>
<%args>
tChannelID channelid;
int channel = 1;
</%args>
<%session scope="global">
Expand All @@ -24,14 +25,6 @@ using namespace vdrlive;
<%cpp>
if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");

dsyslog("vdrlive::stream::f_worker(%p)", f_worker);
if ( !f_worker) {
f_worker = new FFmpegThread();
dsyslog("vdrlive::stream: new FFmpegThread created");
}
f_worker->StartFFmpeg(channel);
dsyslog("vdrlive::stream::StartFFmpeg(%d)", channel);

pageTitle = trVDR("Stream");

#if VDRVERSNUM < 20301
Expand All @@ -40,6 +33,16 @@ using namespace vdrlive;
throw HtmlError( tr("Couldn't aquire access to channels, please try again later.") );
#endif

if ( qparam.has("channelid") ) {
#if VDRVERSNUM >= 20301
LOCK_CHANNELS_READ;
cChannel *c = (cChannel *)Channels->GetByChannelID(channel);
#else
cChannel *c = Channels.GetByChannelID( channelid );
#endif
if ( c ) channel = c->Number();
}

if ( channel > 0 ) {
#if VDRVERSNUM >= 20301
LOCK_CHANNELS_READ;
Expand All @@ -51,6 +54,14 @@ using namespace vdrlive;
if ( Channel == 0 )
throw HtmlError( tr("Couldn't find channel or no channels available. Maybe you mistyped your request?") );

dsyslog("vdrlive::stream::f_worker(%p)", f_worker);
if ( !f_worker) {
f_worker = new FFmpegThread();
dsyslog("vdrlive::stream: new FFmpegThread created");
}
f_worker->StartFFmpeg(channel);
dsyslog("vdrlive::stream::StartFFmpeg(%d)", channel);

</%cpp>
<# <& pageelems.doc_type &> #>
<!DOCTYPE html>
Expand All @@ -66,19 +77,16 @@ using namespace vdrlive;
<div class="inhalt">
<div id="player">

<script src="https://cdn.jsdelivr.net/npm/clappr@0.3.1/dist/clappr.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/clappr@latest/dist/clappr.min.js"></script>
<script>
var player = new Clappr.Player({
source: "/media/master_<$ std::to_string(channel) $>.m3u8",
parentId: "#player",
width: 1280, height: 720,
autoPlay: "true",
liveSyncDurationCount: 2,
playback: {
hlsjsConfig: {
maxBufferLength: 5,
liveMaxBackBufferLength: 10,
}
events: {
onError: function(error) { console.log('Calppr.Player error: ', error); },
onEnded: function() { console.log('Clappr.Player ended'); player.play(); },
}
});
</script>
Expand Down Expand Up @@ -162,8 +170,12 @@ string longDescription = StringEscapeAndBreak(StringWordTruncate(epgEvent->LongD
<form action="stream.html" method="get" id="channels">
<span>
<label for="channel"><$ tr("Channel") $>:&nbsp;<span class="bold"><$ std::to_string(Channel->Number()) $></span></label>
<& channels_widget name=("channel") selected=(Channel ? *Channel->GetChannelID().ToString() : "") onchange=("document.forms.channels.submit()") &>
<& channels_widget name=("channel") selected=(Channel ? *Channel->GetChannelID().ToString() : "") onchange=("player.stop(); document.forms.channels.submit()") &>
<& pageelems.ajax_action_href action="switch_channel" tip=(tr("Switch to this channel.")) param=(Channel->GetChannelID()) image="zap.png" alt="" &>
</span>
</form>
<span class="sep">|</span>
<a href="stream.html?channel=<$ std::max(0, ((int)Channel->Number() - 1)) $>">« Prev</a>
<span class="sep">|</span>
<a href="stream.html?channel=<$ (Channel->Number() + 1) $>">Next »</a>
</%def>

0 comments on commit e7fd453

Please sign in to comment.