Commit 1d098b5d authored by Marvin Scholz's avatar Marvin Scholz Committed by David
Browse files

macosx: VLCOpenInputMetadata: Add initWithPath

Add a new initializer method that takes a file path as NSString
and converts it to a VLC URI, using that to initialize the MRLString
value.

Additionally add a factory method for the initializer too.
parent 40664df3
......@@ -24,6 +24,23 @@
@interface VLCOpenInputMetadata : NSObject
/**
* Create a new VLCOpenInputMetadata with the given file path
*
* See \c -initWithPath: for details.
*/
+ (instancetype)inputMetaWithPath:(NSString *)path;
/**
* Initialize the VLCOpenInputMetadata with the given file path
*
* Initializes the new VLCOpenInputMetadata with the MRLString
* refering to the file given by path. Note that it is not
* verified that the file actually exists, so it will succeed
* regardless of the presence of the file.
*/
- (instancetype)initWithPath:(NSString *)path;
/**
* this is the MRL of the future input item and defines where to search for media
* it is the only required property, because if unset we don't know what to play
......
......@@ -4,6 +4,7 @@
* Copyright (C) 2019 VLC authors and VideoLAN
*
* Authors: Felix Paul Kühne <fkuehne # videolan dot org>
* Marvin Scholz <epirat07 at videolan dot org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -20,8 +21,43 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# import <config.h>
#endif
#import <vlc_common.h>
#import <vlc_url.h>
#import "VLCOpenInputMetadata.h"
@implementation VLCOpenInputMetadata
+ (instancetype)inputMetaWithPath:(NSString *)path
{
return [[VLCOpenInputMetadata alloc] initWithPath:path];
}
- (instancetype)initWithPath:(NSString *)path
{
if (!path)
return nil;
self = [super init];
if (!self)
return nil;
char *vlc_uri_psz = vlc_path2uri([path UTF8String], "file");
if (!vlc_uri_psz)
return nil;
NSString *vlc_uri = [NSString stringWithUTF8String:vlc_uri_psz];
FREENULL(vlc_uri_psz);
if (!vlc_uri)
return nil;
self.MRLString = vlc_uri;
return self;
}
@end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment