Skip to content
Draft
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
1 change: 1 addition & 0 deletions VLCPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export default class VLCPlayer extends Component {
source.isNetwork = isNetwork;
source.autoplay = this.props.autoplay;
source.initOptions = source.initOptions || [];
source.cookies = source.cookies || [];

if (this.props.repeat) {
const existingRepeat = source.initOptions.find(item => item.startsWith('--repeat') || item.startsWith('--input-repeat'));
Expand Down
21 changes: 21 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,27 @@ export interface VLCPlayerSource {
* @default []
*/
initOptions?: string[];
/**
* Cookie jar to fetch HTTP/HTTPS media with. Cookies for non-applicable
* hosts will be ignored. Not supported on MacOS.
*
* From VLCKit's documentation:
* > Parse a value of an incoming Set-Cookie header (see RFC 6265) and
* > append the cookie to the stored cookies if appropriate. The "secure"
* > attribute can be added to cookie to limit the scope of the cookie to
* > secured channels (https).
*
* @example ```js
* [{ value: "name=value; Path=/; Domain=example.com", host: "example.com", path: "/" }]
* ```
*
* @default []
*/
cookies?: {
value: string;
host: string;
path: string;
}[];
}

/**
Expand Down
16 changes: 15 additions & 1 deletion ios/RCTVLCPlayer/RCTVLCPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,21 @@ - (void)setSource:(NSDictionary *)source
// Create dialog provider with custom UI to handle dialogs programmatically
self.dialogProvider = [[VLCDialogProvider alloc] initWithLibrary:library customUI:YES];
self.dialogProvider.customRenderer = self;
_player.media = [VLCMedia mediaWithURL:uri];

VLCMedia* media = [VLCMedia mediaWithURL:uri];

NSArray* cookiesArray = [source objectForKey:@"cookies"];
for (id cookieDict in cookiesArray) {
NSString* value = [cookieDict objectForKey:@"value"];
NSString* host = [cookieDict objectForKey:@"host"];
NSString* path = [cookieDict objectForKey:@"path"];
int cookieStatus = [media storeCookie:value forHost:host path:path];
if (cookieStatus != 0) {
NSLog(@"Failed to store cookie: %@", cookieStatus);
}
}

_player.media = media;

if (_autoplay)
[_player play];
Expand Down