Skip to content

Commit 34bd0d0

Browse files
committed
Add a command to play the first disc
Mostly useful for albums with a bunch of bonus tracks on the second disc, as is common with deluxe edition remasters. Fixes GH-211.
1 parent a5ba412 commit 34bd0d0

File tree

7 files changed

+107
-22
lines changed

7 files changed

+107
-22
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ Doing so isn't fatal (it's not a secret), but it is annoying for other contribut
3737
* You can now switch between now playing and current selection with a tab view.
3838
* Playlist information can be viewed and edited.
3939
* The playlist model has been corrected to handle multiple of the same track. (GH-192)
40+
* Added a command to play the first disc from an album. (GH-211)
4041
* Lower case artist names are properly sorted in the artist list.
4142
* Favouriting items is available from the menu bar, or Cmd+E.
43+
* Adding items to the tracklist now has a shortcut of Cmd+D.
4244
* Fix parsing fractional dates returned by some servers.
4345
* Fix the null cover being used for system now playing information.
4446
* Upgrading from Submariner 1.x is no longer supported.

Submariner/Music.xib

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22690"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<objects>
@@ -66,7 +66,7 @@
6666
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
6767
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
6868
<tableColumns>
69-
<tableColumn identifier="artistName" width="144" minWidth="40" maxWidth="1000" id="21">
69+
<tableColumn identifier="artistName" width="124" minWidth="40" maxWidth="1000" id="21">
7070
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="artistName">
7171
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
7272
<color key="backgroundColor" white="0.33333298560000002" alpha="1" colorSpace="calibratedWhite"/>
@@ -174,11 +174,11 @@
174174
<rect key="frame" x="-1" y="41" width="446" height="199"/>
175175
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
176176
<clipView key="contentView" id="oeS-uH-lBG">
177-
<rect key="frame" x="0.0" y="0.0" width="446" height="184"/>
177+
<rect key="frame" x="0.0" y="0.0" width="446" height="199"/>
178178
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
179179
<subviews>
180180
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnSelection="YES" autosaveName="LocalMusicTable" headerView="36" id="38" customClass="SBTableView">
181-
<rect key="frame" x="0.0" y="0.0" width="692" height="156"/>
181+
<rect key="frame" x="0.0" y="0.0" width="692" height="171"/>
182182
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
183183
<size key="intercellSpacing" width="3" height="2"/>
184184
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -328,7 +328,7 @@
328328
</subviews>
329329
</clipView>
330330
<scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="37">
331-
<rect key="frame" x="0.0" y="184" width="446" height="15"/>
331+
<rect key="frame" x="0.0" y="183" width="446" height="16"/>
332332
<autoresizingMask key="autoresizingMask"/>
333333
</scroller>
334334
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="35">
@@ -406,7 +406,7 @@
406406
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
407407
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
408408
<rect key="contentRect" x="196" y="240" width="404" height="120"/>
409-
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1175"/>
409+
<rect key="screenRect" x="0.0" y="0.0" width="1800" height="1125"/>
410410
<view key="contentView" id="97">
411411
<rect key="frame" x="0.0" y="0.0" width="404" height="120"/>
412412
<autoresizingMask key="autoresizingMask"/>
@@ -538,6 +538,19 @@
538538
<action selector="addAlbumToTracklist:" target="-2" id="G0o-Zq-P2Z"/>
539539
</connections>
540540
</menuItem>
541+
<menuItem isSeparatorItem="YES" id="73S-05-gTS"/>
542+
<menuItem title="Play First Disc" id="6Bo-Ls-nIg">
543+
<modifierMask key="keyEquivalentModifierMask"/>
544+
<connections>
545+
<action selector="playFirstDiscFromAlbum:" target="-2" id="iIp-fk-xty"/>
546+
</connections>
547+
</menuItem>
548+
<menuItem title="Add First Disc to Tracklist" id="Pxi-7v-C0P">
549+
<modifierMask key="keyEquivalentModifierMask"/>
550+
<connections>
551+
<action selector="queueFirstDiscFromAlbum:" target="-1" id="xsa-zY-B1P"/>
552+
</connections>
553+
</menuItem>
541554
<menuItem isSeparatorItem="YES" id="2oY-tZ-Yig"/>
542555
<menuItem title="Delete" id="rvh-F0-V4Q">
543556
<modifierMask key="keyEquivalentModifierMask"/>

Submariner/SBViewController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@
7070
- (IBAction)trackDoubleClick:(id)sender;
7171
- (IBAction)albumDoubleClick:(id)sender;
7272
- (IBAction)playSelected:(id)sender;
73+
- (IBAction)playFirstDiscFromAlbum:(id)sender;
7374
- (IBAction)addArtistToTracklist:(id)sender;
7475
- (IBAction)addAlbumToTracklist:(id)sender;
7576
- (IBAction)addTrackToTracklist:(id)sender;
7677
- (IBAction)addSelectedToTracklist:(id)sender;
78+
- (IBAction)queueFirstDiscFromAlbum:(id)sender;
7779
- (IBAction)createNewLocalPlaylistWithSelectedTracks:(id)sender;
7880
- (IBAction)downloadTrack:(id)sender;
7981
- (IBAction)downloadAlbum:(id)sender;

Submariner/SBViewController.m

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ - (IBAction)playSelected:(id)sender {
112112
}
113113
}
114114

115+
- (IBAction)playFirstDiscFromAlbum:(id)sender {
116+
NSArray<SBTrack*> *tracks = [self firstDiscTracksFor: self.selectedAlbums.firstObject];
117+
[[SBPlayer sharedInstance] playTracks: tracks startingAt: 0];
118+
}
119+
115120
#pragma mark Add to Tracklist
116121

117122
- (IBAction)addArtistToTracklist:(id)sender {
@@ -147,6 +152,12 @@ - (IBAction)addSelectedToTracklist:(id)sender {
147152
}
148153

149154

155+
- (IBAction)queueFirstDiscFromAlbum:(id)sender {
156+
NSArray<SBTrack*> *tracks = [self firstDiscTracksFor: self.selectedAlbums.firstObject];
157+
[[SBPlayer sharedInstance] addTrackArray: tracks replace: NO];
158+
}
159+
160+
150161
- (IBAction)addTrackToTracklist:(id)sender {
151162
[[SBPlayer sharedInstance] addTrackArray: self.selectedTracks replace:NO];
152163
}
@@ -374,6 +385,21 @@ - (void)createLocalPlaylistWithSelected:(NSArray<SBTrack*>*)trackList databaseCo
374385
[playlistsSection addResourcesObject:newPlaylist];
375386
}
376387

388+
- (NSArray<SBTrack*>*)firstDiscTracksFor:(SBAlbum*)album {
389+
NSArray<SBTrack*> *sortedTracks = [album.tracks sortedArrayUsingDescriptors: self.trackSortDescriptor];
390+
NSIndexSet *trackIndices = [sortedTracks indexesOfObjectsPassingTest: ^BOOL(SBTrack * _Nonnull track, NSUInteger index, BOOL * _Nonnull stop) {
391+
// Albums almost always start 1 indexed
392+
return track.discNumber.intValue == 1;
393+
}];
394+
// Fallback if we just don't have numbered discs
395+
if (trackIndices.count == 0) {
396+
trackIndices = [sortedTracks indexesOfObjectsPassingTest: ^BOOL(SBTrack * _Nonnull track, NSUInteger index, BOOL * _Nonnull stop) {
397+
return track.discNumber.intValue == 0;
398+
}];
399+
}
400+
return [sortedTracks objectsAtIndexes: trackIndices];
401+
}
402+
377403
- (SBSelectedItemType) selectedItemType {
378404
NSObject<SBStarrable> *first = self.selectedMusicItems.firstObject;
379405
if ([first isKindOfClass: SBArtist.class]) {
@@ -438,8 +464,10 @@ - (BOOL)validateUserInterfaceItem: (id<NSValidatedUserInterfaceItem>) item {
438464
// for context menus
439465
if (action == @selector(albumDoubleClick:)
440466
|| action == @selector(downloadAlbum:)
441-
|| action == @selector(addAlbumToTracklist:)) {
442-
return albumSelected > 0;
467+
|| action == @selector(addAlbumToTracklist:)
468+
|| action == @selector(playFirstDiscFromAlbum:)
469+
|| action == @selector(queueFirstDiscFromAlbum:)) {
470+
return albumSelected > 0 && albumsActive;
443471
}
444472

445473
if (action == @selector(addArtistToTracklist:)) {

Submariner/ServerHome.xib

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22690"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<objects>
@@ -72,11 +72,11 @@
7272
<rect key="frame" x="-2" y="41" width="622" height="158"/>
7373
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
7474
<clipView key="contentView" id="SWK-O6-Z3Q">
75-
<rect key="frame" x="0.0" y="0.0" width="622" height="143"/>
75+
<rect key="frame" x="0.0" y="0.0" width="622" height="158"/>
7676
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
7777
<subviews>
7878
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnSelection="YES" autosaveName="ServerAlbumsTable" headerView="15" id="13" customClass="SBTableView">
79-
<rect key="frame" x="0.0" y="0.0" width="707" height="115"/>
79+
<rect key="frame" x="0.0" y="0.0" width="707" height="130"/>
8080
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
8181
<size key="intercellSpacing" width="3" height="2"/>
8282
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -237,7 +237,7 @@
237237
</subviews>
238238
</clipView>
239239
<scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="14">
240-
<rect key="frame" x="0.0" y="143" width="622" height="15"/>
240+
<rect key="frame" x="0.0" y="142" width="622" height="16"/>
241241
<autoresizingMask key="autoresizingMask"/>
242242
</scroller>
243243
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="16">
@@ -312,6 +312,19 @@
312312
<action selector="addAlbumToTracklist:" target="-2" id="zDA-gm-oDK"/>
313313
</connections>
314314
</menuItem>
315+
<menuItem isSeparatorItem="YES" id="4sd-vx-bix"/>
316+
<menuItem title="Play First Disc" id="k5I-2Y-c7J">
317+
<modifierMask key="keyEquivalentModifierMask"/>
318+
<connections>
319+
<action selector="playFirstDiscFromAlbum:" target="-2" id="ru9-Xh-94m"/>
320+
</connections>
321+
</menuItem>
322+
<menuItem title="Add First Disc to Tracklist" id="rXg-2R-jU0">
323+
<modifierMask key="keyEquivalentModifierMask"/>
324+
<connections>
325+
<action selector="queueFirstDiscFromAlbum:" target="-2" id="FvQ-zB-R9x"/>
326+
</connections>
327+
</menuItem>
315328
<menuItem isSeparatorItem="YES" id="8z0-m8-feZ"/>
316329
<menuItem title="Download" id="Mkc-gS-tbg">
317330
<modifierMask key="keyEquivalentModifierMask"/>

Submariner/ServerLibrary.xib

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22690"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<objects>
@@ -66,7 +66,7 @@
6666
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
6767
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
6868
<tableColumns>
69-
<tableColumn identifier="itemName" width="144" minWidth="40" maxWidth="1000" id="184">
69+
<tableColumn identifier="itemName" width="124" minWidth="40" maxWidth="1000" id="184">
7070
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
7171
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
7272
<color key="backgroundColor" white="0.33333298560000002" alpha="1" colorSpace="calibratedWhite"/>
@@ -167,11 +167,11 @@
167167
<rect key="frame" x="-2" y="41" width="446" height="199"/>
168168
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
169169
<clipView key="contentView" id="uNg-bD-Z0H">
170-
<rect key="frame" x="0.0" y="0.0" width="446" height="184"/>
170+
<rect key="frame" x="0.0" y="0.0" width="446" height="199"/>
171171
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
172172
<subviews>
173173
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnSelection="YES" autosaveName="ServerMusicTable" headerView="110" id="108" customClass="SBTableView">
174-
<rect key="frame" x="0.0" y="0.0" width="711" height="156"/>
174+
<rect key="frame" x="0.0" y="0.0" width="711" height="171"/>
175175
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
176176
<size key="intercellSpacing" width="3" height="2"/>
177177
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -336,7 +336,7 @@
336336
</subviews>
337337
</clipView>
338338
<scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="109">
339-
<rect key="frame" x="0.0" y="184" width="446" height="15"/>
339+
<rect key="frame" x="0.0" y="183" width="446" height="16"/>
340340
<autoresizingMask key="autoresizingMask"/>
341341
</scroller>
342342
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="111">
@@ -434,6 +434,19 @@
434434
<action selector="addAlbumToTracklist:" target="-2" id="O6Y-vp-Tih"/>
435435
</connections>
436436
</menuItem>
437+
<menuItem isSeparatorItem="YES" id="6zf-07-KHp"/>
438+
<menuItem title="Play First Disc" id="h7O-R5-T2O">
439+
<modifierMask key="keyEquivalentModifierMask"/>
440+
<connections>
441+
<action selector="playFirstDiscFromAlbum:" target="-2" id="Yfw-ZW-kJH"/>
442+
</connections>
443+
</menuItem>
444+
<menuItem title="Add First Disc to Tracklist" id="4G6-ZO-KD9">
445+
<modifierMask key="keyEquivalentModifierMask"/>
446+
<connections>
447+
<action selector="queueFirstDiscFromAlbum:" target="-2" id="4om-Gh-tC7"/>
448+
</connections>
449+
</menuItem>
437450
<menuItem isSeparatorItem="YES" id="vpg-ew-I1e"/>
438451
<menuItem title="Download" id="0xt-vi-X6m">
439452
<modifierMask key="keyEquivalentModifierMask"/>

0 commit comments

Comments
 (0)