[vlc-commits] macosx: add internet browsing
Felix Paul Kühne
git at videolan.org
Sun Jun 30 17:12:29 CEST 2019
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun Jun 30 17:11:55 2019 +0200| [0c9b96e3bdd18da3275e9ab48030e08a2711ccdd] | committer: Felix Paul Kühne
macosx: add internet browsing
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0c9b96e3bdd18da3275e9ab48030e08a2711ccdd
---
modules/gui/macosx/UI/VLCLibraryWindow.xib | 3 +-
modules/gui/macosx/library/VLCLibraryWindow.h | 1 +
modules/gui/macosx/library/VLCLibraryWindow.m | 11 ++-
.../media-source/VLCMediaSourceBaseDataSource.h | 7 +-
.../media-source/VLCMediaSourceBaseDataSource.m | 89 ++++++++++++++++------
.../macosx/media-source/VLCMediaSourceDataSource.m | 2 +-
6 files changed, 83 insertions(+), 30 deletions(-)
diff --git a/modules/gui/macosx/UI/VLCLibraryWindow.xib b/modules/gui/macosx/UI/VLCLibraryWindow.xib
index 30e1dc0d5c..9cc979eeb5 100644
--- a/modules/gui/macosx/UI/VLCLibraryWindow.xib
+++ b/modules/gui/macosx/UI/VLCLibraryWindow.xib
@@ -23,7 +23,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="W1M-0o-qYG">
- <rect key="frame" x="211.5" y="333" width="57" height="23"/>
+ <rect key="frame" x="212" y="333" width="56" height="23"/>
<segmentedCell key="cell" borderStyle="border" alignment="left" style="texturedRounded" trackingMode="selectOne" id="Twg-gp-8ng">
<font key="font" metaFont="system"/>
<segments>
@@ -520,6 +520,7 @@
<outlet property="clearPlaylistButton" destination="cih-xp-HmY" id="PoU-co-0kn"/>
<outlet property="clearPlaylistSeparator" destination="nAW-KH-ipk" id="Af9-fg-u7m"/>
<outlet property="controlsBar" destination="Uzf-Tf-H8x" id="n0G-92-F2Q"/>
+ <outlet property="librarySortButton" destination="Rja-6g-wNZ" id="FQ7-MU-hsk"/>
<outlet property="libraryTargetView" destination="iSp-bV-w6B" id="a94-ux-wUc"/>
<outlet property="mainSplitView" destination="u8g-jy-S4e" id="lI5-wR-kef"/>
<outlet property="mediaSourceCollectionView" destination="r7v-GI-W1U" id="3JJ-GU-o5o"/>
diff --git a/modules/gui/macosx/library/VLCLibraryWindow.h b/modules/gui/macosx/library/VLCLibraryWindow.h
index 64938d24e0..d3b6e5c0a3 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.h
+++ b/modules/gui/macosx/library/VLCLibraryWindow.h
@@ -63,6 +63,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (readwrite, weak) IBOutlet NSView *alternativeAudioView;
@property (readwrite, weak) IBOutlet NSCollectionView *alternativeAudioCollectionView;
@property (readwrite, weak) IBOutlet NSSegmentedControl *alternativeAudioSegmentedControl;
+ at property (readwrite, weak) IBOutlet NSButton *librarySortButton;
@property (readonly) BOOL nativeFullscreenMode;
@property (readwrite) BOOL nonembedded;
diff --git a/modules/gui/macosx/library/VLCLibraryWindow.m b/modules/gui/macosx/library/VLCLibraryWindow.m
index bf34c9982c..2d769366e8 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.m
+++ b/modules/gui/macosx/library/VLCLibraryWindow.m
@@ -378,6 +378,8 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
}
[_videoLibraryCollectionView reloadData];
[_recentVideoLibraryCollectionView reloadData];
+ _librarySortButton.hidden = NO;
+ _alternativeAudioSegmentedControl.hidden = YES;
break;
case 1:
@@ -399,6 +401,8 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
}
[_audioCategorySelectionTableView reloadData];
[_audioCollectionSelectionTableView reloadData];
+ _librarySortButton.hidden = NO;
+ _alternativeAudioSegmentedControl.hidden = NO;
break;
case 2:
@@ -419,6 +423,8 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
[_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_alternativeAudioView(>=444.)]|" options:0 metrics:0 views:dict]];
}
[_alternativeAudioViewController reloadAppearance];
+ _librarySortButton.hidden = NO;
+ _alternativeAudioSegmentedControl.hidden = NO;
break;
default:
@@ -438,8 +444,9 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
[_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_mediaSourceView(>=572.)]|" options:0 metrics:0 views:dict]];
[_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_mediaSourceView(>=444.)]|" options:0 metrics:0 views:dict]];
}
- [_mediaSourceDataSource loadMediaSources];
- [_mediaSourceCollectionView reloadData];
+ _mediaSourceDataSource.mediaSourceMode = _segmentedTitleControl.selectedSegment == 3 ? VLCMediaSourceModeLAN : VLCMediaSourceModeInternet;
+ _librarySortButton.hidden = YES;
+ _alternativeAudioSegmentedControl.hidden = YES;
break;
}
}
diff --git a/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.h b/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.h
index 5fbfb7b70a..7df831c4e2 100644
--- a/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.h
+++ b/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.h
@@ -22,6 +22,11 @@
#import <Cocoa/Cocoa.h>
+typedef NS_ENUM(NSInteger, VLCMediaSourceMode) {
+ VLCMediaSourceModeLAN,
+ VLCMediaSourceModeInternet,
+};
+
NS_ASSUME_NONNULL_BEGIN
@interface VLCMediaSourceBaseDataSource : NSObject
@@ -29,9 +34,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (readwrite) NSCollectionView *collectionView;
@property (readwrite) NSButton *homeButton;
@property (readwrite) NSPathControl *pathControl;
+ at property (readwrite, nonatomic) VLCMediaSourceMode mediaSourceMode;
- (void)setupViews;
-- (void)loadMediaSources;
@end
diff --git a/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m b/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m
index e574912f4a..8813eb0c8a 100644
--- a/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m
+++ b/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m
@@ -83,30 +83,51 @@
- (void)loadMediaSources
{
- NSArray *mediaSourcesOnLAN = [VLCMediaSourceProvider listOfMediaSourcesForCategory:SD_CAT_LAN];
- NSUInteger count = mediaSourcesOnLAN.count;
+ self.pathControl.URL = nil;
+ NSArray *mediaSources;
+ if (self.mediaSourceMode == VLCMediaSourceModeLAN) {
+ mediaSources = [VLCMediaSourceProvider listOfMediaSourcesForCategory:SD_CAT_LAN];
+ } else {
+ mediaSources = [VLCMediaSourceProvider listOfMediaSourcesForCategory:SD_CAT_INTERNET];
+ }
+ NSUInteger count = mediaSources.count;
if (count > 0) {
for (NSUInteger x = 0; x < count; x++) {
- VLCMediaSource *mediaSource = mediaSourcesOnLAN[x];
+ VLCMediaSource *mediaSource = mediaSources[x];
VLCInputNode *rootNode = [mediaSource rootNode];
[mediaSource preparseInputItemWithinTree:rootNode.inputItem];
}
}
- _mediaSources = mediaSourcesOnLAN;
+ _mediaSources = mediaSources;
[self.collectionView reloadData];
}
+- (void)setMediaSourceMode:(VLCMediaSourceMode)mediaSourceMode
+{
+ _mediaSourceMode = mediaSourceMode;
+ [self loadMediaSources];
+ [self homeButtonAction:nil];
+}
+
- (NSInteger)numberOfSectionsInCollectionView:(NSCollectionView *)collectionView
{
- return _mediaSources.count;
+ if (_mediaSourceMode == VLCMediaSourceModeLAN) {
+ return _mediaSources.count;
+ }
+
+ return 1;
}
- (NSInteger)collectionView:(NSCollectionView *)collectionView
numberOfItemsInSection:(NSInteger)section
{
- VLCMediaSource *mediaSource = _mediaSources[section];
- VLCInputNode *rootNode = mediaSource.rootNode;
- return rootNode.numberOfChildren;
+ if (_mediaSourceMode == VLCMediaSourceModeLAN) {
+ VLCMediaSource *mediaSource = _mediaSources[section];
+ VLCInputNode *rootNode = mediaSource.rootNode;
+ return rootNode.numberOfChildren;
+ }
+
+ return _mediaSources.count;
}
- (NSCollectionViewItem *)collectionView:(NSCollectionView *)collectionView
@@ -114,19 +135,25 @@
{
VLCMediaSourceDeviceCollectionViewItem *viewItem = [collectionView makeItemWithIdentifier:VLCMediaSourceDeviceCellIdentifier forIndexPath:indexPath];
- VLCMediaSource *mediaSource = _mediaSources[indexPath.section];
- VLCInputNode *rootNode = mediaSource.rootNode;
- NSArray *nodeChildren = rootNode.children;
- VLCInputNode *childNode = nodeChildren[indexPath.item];
- VLCInputItem *childRootInput = childNode.inputItem;
- viewItem.titleTextField.stringValue = childRootInput.name;
-
- NSURL *artworkURL = childRootInput.artworkURL;
- NSImage *placeholder = [NSImage imageNamed:@"NSApplicationIcon"];
- if (artworkURL) {
- [viewItem.mediaImageView setImageURL:artworkURL placeholderImage:placeholder];
+ if (_mediaSourceMode == VLCMediaSourceModeLAN) {
+ VLCMediaSource *mediaSource = _mediaSources[indexPath.section];
+ VLCInputNode *rootNode = mediaSource.rootNode;
+ NSArray *nodeChildren = rootNode.children;
+ VLCInputNode *childNode = nodeChildren[indexPath.item];
+ VLCInputItem *childRootInput = childNode.inputItem;
+ viewItem.titleTextField.stringValue = childRootInput.name;
+
+ NSURL *artworkURL = childRootInput.artworkURL;
+ NSImage *placeholder = [NSImage imageNamed:@"NXdefaultappicon"];
+ if (artworkURL) {
+ [viewItem.mediaImageView setImageURL:artworkURL placeholderImage:placeholder];
+ } else {
+ viewItem.mediaImageView.image = placeholder;
+ }
} else {
- viewItem.mediaImageView.image = placeholder;
+ VLCMediaSource *mediaSource = _mediaSources[indexPath.item];
+ viewItem.titleTextField.stringValue = mediaSource.mediaSourceDescription;
+ viewItem.mediaImageView.image = [NSImage imageNamed:@"NXFollow"];
}
return viewItem;
@@ -138,17 +165,29 @@
if (!indexPath) {
return;
}
- VLCMediaSource *mediaSource = _mediaSources[indexPath.section];
- VLCInputNode *rootNode = mediaSource.rootNode;
- NSArray *nodeChildren = rootNode.children;
- VLCInputNode *childNode = nodeChildren[indexPath.item];
+
+ VLCMediaSource *mediaSource;
+ VLCInputNode *childNode;
+ _childDataSource = [[VLCMediaSourceDataSource alloc] init];
+
+ if (_mediaSourceMode == VLCMediaSourceModeLAN) {
+ mediaSource = _mediaSources[indexPath.section];
+ VLCInputNode *rootNode = mediaSource.rootNode;
+ NSArray *nodeChildren = rootNode.children;
+ childNode = nodeChildren[indexPath.item];
+ } else {
+ mediaSource = _mediaSources[indexPath.item];
+ childNode = mediaSource.rootNode;
+ }
+
VLCInputItem *childRootInput = childNode.inputItem;
self.pathControl.URL = [NSURL URLWithString:[NSString stringWithFormat:@"vlc://%@", [childRootInput.name stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLPathAllowedCharacterSet]]]];
- _childDataSource = [[VLCMediaSourceDataSource alloc] init];
+
_childDataSource.displayedMediaSource = mediaSource;
_childDataSource.nodeToDisplay = childNode;
_childDataSource.collectionView = self.collectionView;
_childDataSource.pathControl = self.pathControl;
+
self.collectionView.dataSource = _childDataSource;
self.collectionView.delegate = _childDataSource;
[self.collectionView reloadData];
diff --git a/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m b/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m
index 2e5db56097..4710a1c4d3 100644
--- a/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m
+++ b/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m
@@ -88,7 +88,7 @@
VLCInputNode *childNode = nodeChildren[indexPath.item];
VLCInputItem *childRootInput = childNode.inputItem;
- if (childRootInput.inputType == ITEM_TYPE_DIRECTORY) {
+ if (childRootInput.inputType == ITEM_TYPE_DIRECTORY || childRootInput.inputType == ITEM_TYPE_NODE) {
self.pathControl.URL = [NSURL URLWithString:[self.pathControl.URL.path stringByAppendingPathComponent:[childRootInput.name stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLPathAllowedCharacterSet]]]];
self.nodeToDisplay = childNode;
[self.collectionView reloadData];
More information about the vlc-commits
mailing list