Added a human readable title to the media characteristic tags
This commit is contained in:
1 parent
db8ebff2df
commit
d9da44e19b
3 files changed
+94
-26
No files matched your search
@@ -12,36 +12,106 @@
|
|||||||
#pragma mark - Helpers
|
#pragma mark - Helpers
|
||||||
|
|
||||||
@interface SBMediaTag : NSObject {
|
@interface SBMediaTag : NSObject {
|
||||||
|
@private
|
||||||
BOOL _state;
|
BOOL _state;
|
||||||
NSString *_name;
|
NSString *_value;
|
||||||
NSString *_localizedName;
|
NSString *_localizedTitle;
|
||||||
NSString *_localizedDescription;
|
NSString *_localizedDescription;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (NSArray<NSString *> *)predefinedTags;
|
||||||
|
+ (NSArray<NSString *> *)predefinedTagsForMediaType:(NSString *)mediaType;
|
||||||
|
+ (nullable NSString *)localizedDescriptionForTag:(NSString *)tag;
|
||||||
|
|
||||||
@property (nonatomic, readwrite) BOOL state;
|
@property (nonatomic, readwrite) BOOL state;
|
||||||
@property (nonatomic, readonly, nonnull) NSString *name;
|
@property (nonatomic, readonly, nonnull) NSString *value;
|
||||||
|
@property (nonatomic, readonly, nonnull) NSString *localizedTitle;
|
||||||
|
@property (nonatomic, readonly, nonnull) NSString *localizedDescription;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SBMediaTag
|
@implementation SBMediaTag
|
||||||
|
|
||||||
- (instancetype)initWithName:(NSString *)name state:(BOOL)state {
|
- (instancetype)initWithValue:(NSString *)value state:(BOOL)state {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
_state = state;
|
_state = state;
|
||||||
_name = [name copy];
|
_value = [value copy];
|
||||||
|
_localizedTitle = [[SBMediaTag localizedDescriptionForTag:_value] copy];
|
||||||
|
|
||||||
|
if (_localizedTitle == nil) {
|
||||||
|
_localizedTitle = [_value retain];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (NSArray<NSString *> *)predefinedTags {
|
||||||
|
return @[@"public.main-program-content", @"public.auxiliary-content",
|
||||||
|
@"public.subtitles.forced-only", @"public.accessibility.transcribes-spoken-dialog",
|
||||||
|
@"public.accessibility.describes-music-and-sound", @"public.easy-to-read",
|
||||||
|
@"public.accessibility.describes-video", @"public.translation.dubbed",
|
||||||
|
@"public.translation.voice-over", @"public.translation"];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray<NSString *> *)predefinedTagsForMediaType:(NSString *)mediaType {
|
||||||
|
NSMutableArray *tags = [NSMutableArray array];
|
||||||
|
[tags addObjectsFromArray:@[@"public.main-program-content",
|
||||||
|
@"public.auxiliary-content"]];
|
||||||
|
|
||||||
|
if ([mediaType isEqualToString:MP42MediaTypeAudio]) {
|
||||||
|
[tags addObjectsFromArray:@[@"public.accessibility.describes-video",
|
||||||
|
@"public.translation.dubbed",
|
||||||
|
@"public.translation.voice-over"]];
|
||||||
|
}
|
||||||
|
|
||||||
|
else if ([mediaType isEqualToString:MP42MediaTypeSubtitle] ||
|
||||||
|
[mediaType isEqualToString:MP42MediaTypeClosedCaption]) {
|
||||||
|
|
||||||
|
[tags addObjectsFromArray:@[@"public.subtitles.forced-only",
|
||||||
|
@"public.accessibility.transcribes-spoken-dialog",
|
||||||
|
@"public.accessibility.describes-music-and-sound",
|
||||||
|
@"public.easy-to-read"]];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if ([mediaType isEqualToString:MP42MediaTypeSubtitle] ||
|
||||||
|
[mediaType isEqualToString:MP42MediaTypeClosedCaption]) {
|
||||||
|
|
||||||
|
[tags addObjectsFromArray:@[@"public.translation"]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (nullable NSString *)localizedDescriptionForTag:(NSString *)tag {
|
||||||
|
NSDictionary *localizedDescriptions = @{@"public.main-program-content": NSLocalizedString(@"Main Program Content", nil),
|
||||||
|
@"public.auxiliary-content": NSLocalizedString(@"Auxiliary Content", nil),
|
||||||
|
@"public.subtitles.forced-only": NSLocalizedString(@"Contains Only Forced Subtitles", nil),
|
||||||
|
@"public.accessibility.transcribes-spoken-dialog": NSLocalizedString(@"Transcribes Spoken Dialog For Accessibility", nil),
|
||||||
|
@"public.accessibility.describes-music-and-sound": NSLocalizedString(@"Describes Music And Sound For Accessibility", nil),
|
||||||
|
@"public.easy-to-read": NSLocalizedString(@"Easy To Read", nil),
|
||||||
|
@"public.accessibility.describes-video": NSLocalizedString(@"Describes Video For Accessibility", nil),
|
||||||
|
@"public.translation.dubbed": NSLocalizedString(@"Dubbed Translation", nil),
|
||||||
|
@"public.translation.voice-over": NSLocalizedString(@"Voice Over Translation", nil),
|
||||||
|
@"public.translation": NSLocalizedString(@"Language Translation", nil) };
|
||||||
|
return localizedDescriptions[tag];
|
||||||
|
}
|
||||||
|
|
||||||
@synthesize state = _state;
|
@synthesize state = _state;
|
||||||
@synthesize name = _name;
|
@synthesize value= _value;
|
||||||
|
@synthesize localizedTitle = _localizedTitle;
|
||||||
|
@synthesize localizedDescription = _localizedDescription;
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
[_name release];
|
[_value release];
|
||||||
_name = nil;
|
_value = nil;
|
||||||
|
[_localizedTitle release];
|
||||||
|
_localizedTitle = nil;
|
||||||
|
[_localizedDescription release];
|
||||||
|
_localizedDescription = nil;
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +135,7 @@
|
|||||||
[_representedTag autorelease];
|
[_representedTag autorelease];
|
||||||
_representedTag = [representedTag retain];
|
_representedTag = [representedTag retain];
|
||||||
|
|
||||||
_checkBox.title = _representedTag.name;
|
_checkBox.title = _representedTag.localizedTitle;
|
||||||
_checkBox.state = _representedTag.state;
|
_checkBox.state = _representedTag.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,18 +163,15 @@
|
|||||||
self = [self init];
|
self = [self init];
|
||||||
if (self) {
|
if (self) {
|
||||||
_track = [track retain];
|
_track = [track retain];
|
||||||
NSArray *predefinedTags = @[@"public.main-program-content", @"public.auxiliary-content",
|
NSArray<NSString *> *predefinedTags = [SBMediaTag predefinedTagsForMediaType:track.mediaType];
|
||||||
@"public.subtitles.forced-only", @"public.accessibility.transcribes-spoken-dialog",
|
|
||||||
@"public.accessibility.describes-music-and-sound", @"public.easy-to-read",
|
|
||||||
@"public.accessibility.describes-video", @"public.translation.dubbed",
|
|
||||||
@"public.translation.voice-over", @"public.translation"];
|
|
||||||
|
|
||||||
NSMutableArray<SBMediaTag *> *tags = [[NSMutableArray alloc] init];
|
NSMutableArray<SBMediaTag *> *tags = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
// Add the predefined tags
|
// Add the predefined tags
|
||||||
for (NSString *availableTag in predefinedTags) {
|
for (NSString *availableTag in predefinedTags) {
|
||||||
BOOL state = [track.mediaCharacteristicTags containsObject:availableTag] ? YES : NO;
|
BOOL state = [track.mediaCharacteristicTags containsObject:availableTag] ? YES : NO;
|
||||||
SBMediaTag *tag = [[SBMediaTag alloc] initWithName:availableTag state:state];
|
SBMediaTag *tag = [[SBMediaTag alloc] initWithValue:availableTag
|
||||||
|
state:state];
|
||||||
[tags addObject:tag];
|
[tags addObject:tag];
|
||||||
[tag release];
|
[tag release];
|
||||||
}
|
}
|
||||||
@@ -114,7 +181,7 @@
|
|||||||
[custom minusSet:[NSSet setWithArray:predefinedTags]];
|
[custom minusSet:[NSSet setWithArray:predefinedTags]];
|
||||||
|
|
||||||
for (NSString *customTag in custom) {
|
for (NSString *customTag in custom) {
|
||||||
SBMediaTag *tag = [[SBMediaTag alloc] initWithName:customTag state:YES];
|
SBMediaTag *tag = [[SBMediaTag alloc] initWithValue:customTag state:YES];
|
||||||
[tags addObject:tag];
|
[tags addObject:tag];
|
||||||
[tag release];
|
[tag release];
|
||||||
}
|
}
|
||||||
@@ -166,7 +233,7 @@
|
|||||||
|
|
||||||
for (SBMediaTag *tag in self.tags) {
|
for (SBMediaTag *tag in self.tags) {
|
||||||
if (tag.state == YES) {
|
if (tag.state == YES) {
|
||||||
[set addObject:tag.name];
|
[set addObject:tag.value];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="8191" systemVersion="15A282a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="8191" systemVersion="15A282a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<deployment identifier="macosx"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="8191"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="8191"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<objects>
|
<objects>
|
||||||
@@ -15,20 +16,20 @@
|
|||||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5">
|
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5">
|
||||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||||
<rect key="contentRect" x="196" y="240" width="480" height="341"/>
|
<rect key="contentRect" x="196" y="240" width="480" height="238"/>
|
||||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
|
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
|
||||||
<view key="contentView" id="se5-gp-TjO">
|
<view key="contentView" id="se5-gp-TjO">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="480" height="341"/>
|
<rect key="frame" x="0.0" y="0.0" width="480" height="238"/>
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Zzf-gN-TUn">
|
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Zzf-gN-TUn">
|
||||||
<rect key="frame" x="20" y="61" width="440" height="230"/>
|
<rect key="frame" x="20" y="61" width="440" height="127"/>
|
||||||
<clipView key="contentView" id="2tz-9C-6LP">
|
<clipView key="contentView" id="2tz-9C-6LP">
|
||||||
<rect key="frame" x="1" y="1" width="438" height="228"/>
|
<rect key="frame" x="1" y="1" width="438" height="125"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="yBQ-Mz-XbW">
|
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="yBQ-Mz-XbW">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="438" height="0.0"/>
|
<rect key="frame" x="0.0" y="0.0" width="438" height="125"/>
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
<animations/>
|
<animations/>
|
||||||
<size key="intercellSpacing" width="3" height="2"/>
|
<size key="intercellSpacing" width="3" height="2"/>
|
||||||
@@ -100,7 +101,7 @@
|
|||||||
</scroller>
|
</scroller>
|
||||||
</scrollView>
|
</scrollView>
|
||||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4kV-dT-0Ea">
|
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4kV-dT-0Ea">
|
||||||
<rect key="frame" x="18" y="304" width="444" height="17"/>
|
<rect key="frame" x="18" y="201" width="444" height="17"/>
|
||||||
<animations/>
|
<animations/>
|
||||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Select the media characteristic tags for this track." id="s8w-ML-LZK">
|
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Select the media characteristic tags for this track." id="s8w-ML-LZK">
|
||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
@@ -155,7 +156,7 @@ DQ
|
|||||||
<connections>
|
<connections>
|
||||||
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
|
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
|
||||||
</connections>
|
</connections>
|
||||||
<point key="canvasLocation" x="249" y="-17.5"/>
|
<point key="canvasLocation" x="562" y="-217"/>
|
||||||
</window>
|
</window>
|
||||||
</objects>
|
</objects>
|
||||||
</document>
|
</document>
|
||||||
@@ -521,7 +521,6 @@
|
|||||||
A961475E13F5676E0068F161 /* NIBs */ = {
|
A961475E13F5676E0068F161 /* NIBs */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
A998DABD1BA54CFF004D7969 /* SBMediaTagsController.xib */,
|
|
||||||
A9B46AC012B79E230040517A /* SBDocument.xib */,
|
A9B46AC012B79E230040517A /* SBDocument.xib */,
|
||||||
A9AB485A17F0AEFD000AA72E /* ChapterView.xib */,
|
A9AB485A17F0AEFD000AA72E /* ChapterView.xib */,
|
||||||
A9AB485C17F0AEFD000AA72E /* EmptyView.xib */,
|
A9AB485C17F0AEFD000AA72E /* EmptyView.xib */,
|
||||||
@@ -537,6 +536,7 @@
|
|||||||
A9BC410618D9ABC000F8C92C /* QueueItem.xib */,
|
A9BC410618D9ABC000F8C92C /* QueueItem.xib */,
|
||||||
A90B023910F3290A000416F3 /* Prefs.xib */,
|
A90B023910F3290A000416F3 /* Prefs.xib */,
|
||||||
A9C5FA7219FA2FEC0051F3FF /* SBLogWindow.xib */,
|
A9C5FA7219FA2FEC0051F3FF /* SBLogWindow.xib */,
|
||||||
|
A998DABD1BA54CFF004D7969 /* SBMediaTagsController.xib */,
|
||||||
A9DA3BA11B918D6F00F1E40C /* ExceptionAlert.xib */,
|
A9DA3BA11B918D6F00F1E40C /* ExceptionAlert.xib */,
|
||||||
);
|
);
|
||||||
name = NIBs;
|
name = NIBs;
|
||||||
|
|||||||
Reference in new issue
Block a user