Skip to content

Commit

Permalink
Merge pull request #332 from sapireli/electron
Browse files Browse the repository at this point in the history
feat: support for setting channel HTTP referrer headers for HTML 5 Player & JS Player
  • Loading branch information
4gray committed Dec 6, 2023
2 parents fea3ab2 + 5e90083 commit acb8980
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
8 changes: 3 additions & 5 deletions electron/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,12 @@ export class Api {
.on(
CHANNEL_SET_USER_AGENT,
(_event, args: { userAgent: string; referer?: string }) => {
if (args.userAgent && args.referer !== undefined) {
if (args.userAgent || args.referer !== undefined) {
this.setUserAgent(
args.userAgent,
args.userAgent || 'localhost',
args.referer || 'localhost'
);
} else {
this.setUserAgent(this.defaultUserAgent, 'localhost');
}
}
}
)
.on(IS_PLAYLISTS_MIGRATION_POSSIBLE, (event) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
import Hls from 'hls.js';
import { Channel } from '../../../../../shared/channel.interface';
import { getExtensionFromUrl } from '../../../../../shared/playlist.utils';
import { DataService } from '../../../services/data.service';
import { CHANNEL_SET_USER_AGENT } from '../../../../../shared/ipc-commands';

/**
* This component contains the implementation of HTML5 based video player
Expand All @@ -23,6 +25,11 @@ import { getExtensionFromUrl } from '../../../../../shared/playlist.utils';
export class HtmlVideoPlayerComponent implements OnChanges, OnDestroy {
/** Channel to play */
@Input() channel: Channel;
dataService: DataService; // Declare the dataService property

constructor(dataService: DataService) {
this.dataService = dataService; // Inject the DataService
}

/** Video player DOM element */
@ViewChild('videoPlayer', { static: true })
Expand Down Expand Up @@ -63,6 +70,10 @@ export class HtmlVideoPlayerComponent implements OnChanges, OnDestroy {
this.hls = new Hls();
this.hls.attachMedia(this.videoPlayer.nativeElement);
this.hls.loadSource(url);
this.dataService.sendIpcEvent(CHANNEL_SET_USER_AGENT, {
userAgent: channel.http['user-agent'],
referer: channel.http.referrer,
});
this.handlePlayOperation();
} else {
console.error('something wrong with hls.js init...');
Expand All @@ -71,6 +82,10 @@ export class HtmlVideoPlayerComponent implements OnChanges, OnDestroy {
url,
'video/mp4'
);
this.dataService.sendIpcEvent(CHANNEL_SET_USER_AGENT, {
userAgent: channel.http['user-agent'],
referer: channel.http.referrer,
});
this.videoPlayer.nativeElement.play();
}
}
Expand Down

1 comment on commit acb8980

@vercel
Copy link

@vercel vercel bot commented on acb8980 Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

iptvnator – ./

iptvnator-git-electron-4gray.vercel.app
iptvnator-4gray.vercel.app
iptvnator.vercel.app

Please sign in to comment.