[vlc-commits] [Git][videolan/vlc][master] 2 commits: macosx: show chapter duration instead of start offset in sidebar

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Fri Apr 17 21:58:33 UTC 2026



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
70138f9b by Felix Paul Kühne at 2026-04-17T23:20:32+02:00
macosx: show chapter duration instead of start offset in sidebar

Derive each chapter's duration from the difference with the next
chapter's start time (or the title length for the last one), expose
it on VLCPlayerChapter as duration/durationString, and rebind the
sidebar column to display it. Falls back to --:-- when the computed
duration is not positive.

- - - - -
326d258d by Felix Paul Kühne at 2026-04-17T23:20:32+02:00
macosx: select chapters by index from sidebar

Use VLCPlayerController's selectedChapterIndex rather than seeking to
the chapter's start time. The index-based path matches what the
Playback > Chapter menu does and works on access modules that do not
expose per-chapter time offsets.

- - - - -


5 changed files:

- modules/gui/macosx/UI/VLCLibraryWindowChaptersView.xib
- modules/gui/macosx/library/VLCLibraryWindowChaptersSidebarViewController.m
- modules/gui/macosx/playqueue/VLCPlayerChapter.h
- modules/gui/macosx/playqueue/VLCPlayerChapter.m
- modules/gui/macosx/playqueue/VLCPlayerTitle.m


Changes:

=====================================
modules/gui/macosx/UI/VLCLibraryWindowChaptersView.xib
=====================================
@@ -67,7 +67,7 @@
                                         </prototypeCellViews>
                                     </tableColumn>
                                     <tableColumn identifier="VLCLibraryWindowChaptersTableViewTimeColumnIdentifier" editable="NO" width="64" minWidth="64" maxWidth="100" id="KEN-Nu-Iyj">
-                                        <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Time">
+                                        <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Duration">
                                             <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
                                             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                         </tableHeaderCell>


=====================================
modules/gui/macosx/library/VLCLibraryWindowChaptersSidebarViewController.m
=====================================
@@ -117,7 +117,12 @@
     NSMutableArray * const chapters = [NSMutableArray arrayWithCapacity:chapterCount];
     for (size_t i = 0; i < chapterCount; i++) {
         struct vlc_player_chapter p_chapter = pp_chapters[i];
-        VLCPlayerChapter * const chapter = [[VLCPlayerChapter alloc] initWithChapter:&p_chapter];
+        const vlc_tick_t nextTime = (i + 1 < chapterCount)
+            ? pp_chapters[i + 1].time
+            : title->length;
+        const vlc_tick_t duration = nextTime - p_chapter.time;
+        VLCPlayerChapter * const chapter =
+            [[VLCPlayerChapter alloc] initWithChapter:&p_chapter duration:duration];
         [chapters addObject:chapter];
     }
     self.chaptersArrayController.content = chapters.copy;
@@ -126,13 +131,13 @@
 
 - (IBAction)tableViewAction:(id)sender
 {
-    VLCPlayerChapter * const selectedChapter =
-        self.chaptersArrayController.selectedObjects.firstObject;
-    if (selectedChapter == nil) {
+    const NSUInteger selectedIndex = self.chaptersArrayController.selectionIndex;
+    if (selectedIndex == NSNotFound) {
         return;
     }
 
-    [VLCMain.sharedInstance.playQueueController.playerController setTimeFast:selectedChapter.time];
+    VLCMain.sharedInstance.playQueueController.playerController.selectedChapterIndex =
+        selectedIndex;
 }
 
 - (void)chapterSelectionChanged:(NSNotification *)notification
@@ -169,7 +174,7 @@
                                         owner:self];
         [cellView.textField bind:NSValueBinding
                             toObject:cellView
-                         withKeyPath:@"objectValue.timeString"
+                         withKeyPath:@"objectValue.durationString"
                              options:nil];
         return cellView;
     }


=====================================
modules/gui/macosx/playqueue/VLCPlayerChapter.h
=====================================
@@ -32,8 +32,11 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readonly) NSString *name;
 @property (readonly) vlc_tick_t time;
 @property (readonly) NSString *timeString;
+ at property (readonly) vlc_tick_t duration;
+ at property (readonly) NSString *durationString;
 
-- (instancetype)initWithChapter:(const struct vlc_player_chapter *)p_chapter;
+- (instancetype)initWithChapter:(const struct vlc_player_chapter *)p_chapter
+                       duration:(vlc_tick_t)duration;
 
 @end
 


=====================================
modules/gui/macosx/playqueue/VLCPlayerChapter.m
=====================================
@@ -27,12 +27,17 @@
 @implementation VLCPlayerChapter
 
 - (instancetype)initWithChapter:(const struct vlc_player_chapter *)p_chapter
+                       duration:(vlc_tick_t)duration
 {
     self = [super init];
     if (self && p_chapter != NULL) {
         _name = toNSStr(p_chapter->name);
         _time = p_chapter->time;
         _timeString = [NSString stringWithTimeFromTicks:_time];
+        _duration = duration;
+        _durationString = duration > 0
+            ? [NSString stringWithTimeFromTicks:duration]
+            : @"--:--";
     }
     return self;
 }


=====================================
modules/gui/macosx/playqueue/VLCPlayerTitle.m
=====================================
@@ -39,9 +39,14 @@
         _chapterCount = p_title->chapter_count;
 
         NSMutableArray * const chapters = [NSMutableArray arrayWithCapacity:self.chapterCount];
-        for (int i = 0; i < self.chapterCount; i++) {
+        for (NSUInteger i = 0; i < self.chapterCount; i++) {
+            const vlc_tick_t nextTime = (i + 1 < self.chapterCount)
+                ? p_title->chapters[i + 1].time
+                : p_title->length;
+            const vlc_tick_t duration = nextTime - p_title->chapters[i].time;
             VLCPlayerChapter * const chapter =
-                [[VLCPlayerChapter alloc] initWithChapter:&p_title->chapters[i]];
+                [[VLCPlayerChapter alloc] initWithChapter:&p_title->chapters[i]
+                                                 duration:duration];
             [chapters addObject:chapter];
         }
         _chapters = chapters.copy;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5cd144b72beaa919be26c54a8e95450a231c4eb9...326d258d13569d81d4473cd8752522fc64cd52c9

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5cd144b72beaa919be26c54a8e95450a231c4eb9...326d258d13569d81d4473cd8752522fc64cd52c9
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list