Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WebRTC, HLS and DASH buttons to Web Panel #184

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 38 additions & 12 deletions src/app/app.page/app.page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -759,19 +759,45 @@ <h4 class="card-title text-left" i18n="@@newLiveStreamCardTitle">


<!-- Play Button -->
<ul class="nav navbar-right" *ngIf="row.status=='broadcasting'">
<li class="dropdown">
<a href="#" class="dropdown-toggle btn-magnify" data-toggle="dropdown">
<i class="ti-control-play"></i> Play Live
<span class="notification"></span>
<b class="caret"></b>
<p class="hidden-md hidden-lg">
</p>
</a>
<ul class="dropdown-menu">
<li><a (click)="playLive(row.streamId, 'webrtc')"
data-toggle="tooltip" type="button"
class="dropdown-link">
<span>
<i class="ti-control-play"></i> Play WebRTC
</span>
</a>
</li>

<li><a (click)="playLive(row.streamId, 'hls')"
data-toggle="tooltip" type="button"
class="dropdown-link">
<span>
<i class="ti-control-play"></i> Play HLS
</span>
</a>
</li>

<button
*ngIf="row.status=='broadcasting' && (appSettings.webRTCEnabled == true|| appSettings.hlsMuxingEnabled == true) "
data-toggle="tooltip" i18n-title title="Play Stream"
(click)="playLive(row.streamId)"
class="btn btn-success btn-simple btn-magnify btn-xs big-icons"
type="button">
<span class="btn-label">
<i class="ti-control-play"></i>
</span>
<ng-container i18n="@@tablePlayButton"></ng-container>
</button>

<li><a (click)="playLive(row.streamId, 'dash')"
data-toggle="tooltip" type="button"
class="dropdown-link">
<span>
<i class="ti-control-play"></i> Play DASH
</span>
</a>
</li>
</ul>
</li>
</ul>

<button
*ngIf="row.status=='broadcasting' && appSettings.webRTCEnabled == false && appSettings.hlsMuxingEnabled == false"
Expand Down
69 changes: 51 additions & 18 deletions src/app/app.page/app.page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,28 +798,61 @@ export class AppPageComponent implements OnInit, OnDestroy, AfterViewInit {

}

getIFrameSrc(streamId: string, autoplay: string, token: string): string {
getIFrameSrc(streamId: string, autoplay: string, token: string, playMethod: string): string {
return HTTP_SERVER_ROOT + this.appName + "/play.html?name=" + streamId + "&autoplay=" + autoplay +
(token != null ? "&token=" + token : "");
(token != null ? "&token=" + token : "") + "&playOrder=" + playMethod;
}

getIFrameEmbedCode(streamId: string): string {
return '<iframe id="' + streamId + '" frameborder="0" allowfullscreen="true" class = "frame" seamless="seamless" style="display:block; width:100%; height:480px" ></iframe>';
}

playLive(streamId: string): void {
playLive(streamId: string, playMethod: string): void {

// Let's check if it's community edition or play method settings are not enabled
if((playMethod == "webrtc" || playMethod == "dash") && !this.isEnterpriseEdition){
$.notify({
icon: "ti-save",
message: "You need to use Enterprise Edition for using WebRTC or DASH."
}, {
type: "warning",
delay: 4000,
placement: {
from: 'top',
align: 'right'
}
});
}

if((playMethod == "webrtc" && !this.appSettings.webRTCEnabled) ||
(playMethod == "hls" && !this.appSettings.hlsMuxingEnabled) ||
(playMethod == "dash" && !this.appSettings.dashMuxingEnabled)){
$.notify({
icon: "ti-save",
message: "Please enable "+playMethod+" on app settings"
}, {
type: "warning",
delay: 4000,
placement: {
from: 'top',
align: 'right'
}
});
return;
}

if (this.appSettings.playTokenControlEnabled) {
this.openPlayerWithOneTimeToken(streamId, streamId, "640px", streamId);
this.openPlayerWithOneTimeToken(streamId, streamId, "640px", streamId, playMethod);
}
if (this.appSettings.playJwtControlEnabled) {
this.openPlayerWithJWTToken(streamId, streamId, "640px", streamId);
this.openPlayerWithJWTToken(streamId, streamId, "640px", streamId, playMethod);
}
else {
this.openPlayer(this.getIFrameEmbedCode(streamId), streamId, streamId, "640px", null);
this.openPlayer(this.getIFrameEmbedCode(streamId), streamId, streamId, "640px", null, playMethod);
}
}

openPlayer(htmlCode: string, objectId: string, streamId: string, width: string, tokenId: string): void {
openPlayer(htmlCode: string, objectId: string, streamId: string, width: string, tokenId: string, playMethod: string): void {

swal({
html: htmlCode,
Expand All @@ -831,7 +864,7 @@ export class AppPageComponent implements OnInit, OnDestroy, AfterViewInit {
onOpen: () => {
//the error in this callback does not show up in browser console.
var iframe = $('#' + objectId);
iframe.prop('src', this.getIFrameSrc(streamId, "true", tokenId));
iframe.prop('src', this.getIFrameSrc(streamId, "true", tokenId, playMethod));
},
onClose: function () {
var ifr = document.getElementById(objectId);
Expand Down Expand Up @@ -867,7 +900,7 @@ export class AppPageComponent implements OnInit, OnDestroy, AfterViewInit {
for (var i in this.broadcastGridTableData.dataRows) {
id = this.broadcastGridTableData.dataRows[i]['streamId'];
var $iframe = $('#' + id);
$iframe.prop('src', this.getIFrameSrc(id, "true", null));
$iframe.prop('src', this.getIFrameSrc(id, "true", null, "webrtc,hls"));
}

}, 1500);
Expand Down Expand Up @@ -903,14 +936,14 @@ export class AppPageComponent implements OnInit, OnDestroy, AfterViewInit {
playVoD(vodName: string, type: string, vodId: string, streamId: string, filePath: string): void {

if (this.appSettings.playTokenControlEnabled || this.appSettings.playJwtControlEnabled) {
this.playVoDToken(vodName, type, vodId, streamId, filePath);
this.playVoDToken(vodName, type, vodId, streamId, filePath , "vod");
}
else {
this.openPlayer(this.getIFrameEmbedCode(vodId), vodId, filePath, "640px", null);
this.openPlayer(this.getIFrameEmbedCode(vodId), vodId, filePath, "640px", null, "vod");
}
}

playVoDToken(name: string, type: string, vodId: string, streamId: string, filePath: string): void {
playVoDToken(name: string, type: string, vodId: string, streamId: string, filePath: string, playMethod: string): void {
let tokenParam;

if (type == "uploadedVod") {
Expand All @@ -925,10 +958,10 @@ export class AppPageComponent implements OnInit, OnDestroy, AfterViewInit {
}

if (tokenParam != null && this.appSettings.playTokenControlEnabled) {
this.openPlayerWithOneTimeToken(vodId, filePath, "640px", tokenParam);
this.openPlayerWithOneTimeToken(vodId, filePath, "640px", tokenParam, "vod");
}
else if (tokenParam != null && this.appSettings.playJwtControlEnabled) {
this.openPlayerWithJWTToken(vodId, filePath, "640px", tokenParam);
this.openPlayerWithJWTToken(vodId, filePath, "640px", tokenParam, "vod");
}
else {
swal({
Expand All @@ -945,23 +978,23 @@ export class AppPageComponent implements OnInit, OnDestroy, AfterViewInit {
}


openPlayerWithOneTimeToken(id: string, path: string, width: string, tokenParam: string) {
openPlayerWithOneTimeToken(id: string, path: string, width: string, tokenParam: string, playMethod: string) {
let currentUnixTime: number = Math.floor(Date.now() / 1000)
let expireDate: number = currentUnixTime + 100;

this.restService.getOneTimeToken(this.appName, tokenParam, expireDate).subscribe(data => {
this.token = <Token>data;
this.openPlayer(this.getIFrameEmbedCode(id), id, path, "640px", this.token.tokenId)
this.openPlayer(this.getIFrameEmbedCode(id), id, path, "640px", this.token.tokenId, playMethod)
}, error => { show403Error(error); });
}

openPlayerWithJWTToken(id: string, path: string, width: string, tokenParam: string) {
openPlayerWithJWTToken(id: string, path: string, width: string, tokenParam: string, playMethod: string) {
let currentUnixTime: number = Math.floor(Date.now() / 1000)
let expireDate: number = currentUnixTime + 100;

this.restService.getJWTToken(this.appName, tokenParam, expireDate).subscribe(data => {
this.token = <Token>data;
this.openPlayer(this.getIFrameEmbedCode(id), id, path, "640px", this.token.tokenId)
this.openPlayer(this.getIFrameEmbedCode(id), id, path, "640px", this.token.tokenId, playMethod)
}, error => { show403Error(error); });
}

Expand Down
10 changes: 3 additions & 7 deletions src/assets/css/ant-media.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,16 @@ select.selectpicker {
flex: 0 1 25%!important;
}
.status-column{
flex: 0 1 25% !important;
flex: 0 1 15% !important;
}
.viewer-column{
flex: 0 1 25% !important;
}
.social-column{
flex: 0 1 15% !important;
flex: 0 1 20% !important;
}
.action-column{
flex: 0 1 25% !important;
flex: 0 1 40% !important;
justify-content:flex-end;
}
.justify-flex-end {
justify-content:flex-end;
}