Skip to content

VLCMediaPlayer: Refactoring titleDescriptions

Hank Anderson requested to merge Sumou/VLCKit:new-title-description into master

I tried to refactor titleDescriptions to make it more intuitive. You will have access to more detailed information.

Before

VLCMediaPlayer *mediaPlayer = ...;

// detail
NSArray *titleDescriptions = mediaPlayer.titleDescriptions;
[titleDescriptions enumerateObjectsUsingBlock:^(id  _Nonnull titleDescriptionDic, NSUInteger idx, BOOL * _Nonnull stop) {

    NSString *titleName = titleDescriptionDic[VLCTitleDescriptionName];
    NSNumber *duration = titleDescriptionDic[VLCTitleDescriptionDuration];
    NSNumber *isMenu = titleDescriptionDic[VLCTitleDescriptionIsMenu];

    NSArray *chapterDescriptions = [mediaPlayer chapterDescriptionsOfTitle: (int)idx];        
    for (NSDictionary *chapterDescriptionDic in chapterDescriptions) {
            
        NSString *chapterName = chapterDescriptionDic[VLCChapterDescriptionName];
        NSNumber *duration = chapterDescriptionDic[VLCChapterDescriptionDuration];
        NSNumber *timeOffset = chapterDescriptionDic[VLCChapterDescriptionTimeOffset];
            
    }
        
}];

After

VLCMediaPlayer *mediaPlayer = ...;

// detail 
NSArray<VLCMediaPlayerTitleDescription *> *titleDescriptions = mediaPlayer.titleDescriptions;
for (VLCMediaPlayerTitleDescription *titleDescription in titleDescriptions) {
        
    NSString *titleName = titleDescription.name;
    VLCTime *duration = titleDescription.durationTime;
    VLCMediaPlayerTitleType titleType = titleDescription.titleType;
    int titleIndex = titleDescription.titleIndex;
    NSURL *mediaURL = titleDescription.mediaURL;
    BOOL isCurrent = titleDescription.isCurrent;
    BOOL isMenu = titleDescription.isMenu;
        
    NSArray<VLCMediaPlayerChapterDescription *> *chapterDescriptions = titleDescription.chapterDescriptions;
    for (VLCMediaPlayerChapterDescription *chapterDescription in chapterDescriptions) {
            
        NSString *chapterName = chapterDescription.name;
        VLCTime *duration = chapterDescription.durationTime;
        VLCTime *timeOffset = chapterDescription.timeOffset;
        int titleIndex = chapterDescription.titleIndex;
        int chapterIndex = chapterDescription.chapterIndex;
        NSURL *mediaURL = chapterDescription.mediaURL;
        BOOL isCurrent = chapterDescription.isCurrent;
            
    }
        
}

// You can set Current from object
VLCMediaPlayerTitleDescription *titleDescription = ...;
[titleDescription setCurrent];
    
VLCMediaPlayerChapterDescription *chapterDescription = ...;
[chapterDescription setCurrent];
Edited by Hank Anderson

Merge request reports

Loading