![]() |
AliyunPlayer v7.11.0
Aliyun Player API Reference Manual for iOS Platforms
|
VTT subtitle rendering implementation class. More...
#include "AliVttSubtitleView.h"
Instance Methods | |
| (void) | - actualShow:withContext: |
| Actually display subtitle. | |
| (void) | - applyBackgroundColorStyle:contentAttribute: |
| Apply background color style. | |
| (void) | - applyColorStyle:contentAttribute: |
| Apply text color style. | |
| (void) | - applyDecorationStyle:contentAttribute: |
| Apply text decoration styles (underline, strikethrough, etc.) | |
| (void) | - applyFontStyle:contentAttribute:context: |
| Apply font style. | |
| (void) | - applyLayerSetting:styleStr: |
| Apply layer settings. | |
| (void) | - applyStrokeAndShadow:contentAttribute:context: |
| Apply stroke and shadow effects. | |
| (CGFloat) | - calculateMaxTextWidth |
| Calculate maximum text width. | |
| (void) | - clear |
| Clear all subtitle display content. | |
| (BOOL) | - containsFullWidthCharacters: |
| Detect if string contains full-width characters. | |
| (BOOL) | - containsUpperGlyphCharacters: |
| Detect if string contains superscript characters. | |
| (NSAttributedString *) | - createStyledText:dialogueObj:withContext: |
| Create styled attributed text. | |
| (NSAttributedString *) | - createStyledTextSegment:context: |
| Create styled string for single text segment. | |
| (void) | - customizeAttribuets:locationAttribute: |
| Customize content attributes and location information (for subclass override) | |
| (UIFont *) | - customizeFont:contentAttribute:contentText: |
| Customize font (for subclass override) | |
| (void) | - customizeParagraphStyle:withFont:contentText: |
| Customize paragraph style (for subclass override) | |
| (AliVttDialogueObj *) | - findDialogueObjByIdx: |
| Find subtitle dialogue object by index. | |
| (AliVttDialogueObj *) | - findIdleDialogueObj |
| Find idle subtitle dialogue object. | |
| (UIFont *) | - generateFontWithName:fontSize:isBold:isItalic: |
| Generate font with specified style. | |
| (void) | - getActualTextPositions:withContext: |
| Calculate subtitle display position. | |
| (void) | - getActualTextSize:dialogue:withContext: |
| Calculate actual text size. | |
| (UIColor *) | - getColorFromValue: |
| Create UIColor object from integer value. | |
| (void) | - getParentViewSize:h: |
| Get parent view size. | |
| (CGSize) | - getSizeFromStr:withMaxtextWidth: |
| Calculate display size of attributed text. | |
| (nullable AliWebVttHeader *) | - getVttHeader |
| Get VTT header information. | |
| (void) | - hideDialogue:atIndex: |
| Hide subtitle at specified index. | |
| (void) | - initialDialogueObj:index: |
| Initialize subtitle dialogue object. | |
| (CGPoint) | - maybeApplyDefaultPosition:withContext: |
| Apply default position rules. | |
| (CGFloat) | - maybeForcebeCenter:withContext: |
| Force center alignment (when position is out of range) | |
| (CGFloat) | - maybeUpperThanBase:withContext: |
| Ensure position is above baseline. | |
| (RenderContext *) | - prepareRenderContext |
| Prepare rendering context. | |
| (CGPoint) | - processAttributePosition:withContext: |
| Process location attributes and calculate base coordinates. | |
| (CGFloat) | - processXPositon:withContext: |
| Process X direction position. | |
| (CGFloat) | - processYPosition:withContext: |
| Process Y direction position. | |
| (void) | - renderSubtitleContent:contentAttributes:locationAttribute: |
| Main method for rendering subtitle content. | |
| (void) | - safelyRemoveObserverIfNeeded |
| Safely remove observer. | |
| (void) | - setup: |
| Initialize renderer and set parent layer. | |
| (void) | - setVttHeader: |
| Set VTT header information. | |
| (void) | - showDialogue:atIndex: |
| Show subtitle at specified index. | |
| (RenderContext *) | - updateRenderContext:withSubStr: |
| Update rendering context. | |
| (void) | - updateVideoDisPlay:height:scaleMode: |
| Update video display information. | |
Properties | |
| Class | constClass |
| 全局常量类,所有实例共享 Global constant class shared by all instances | |
| NSMutableArray * | dialogueArr |
| 管理的字幕对话框对象数组 Array of managed subtitle dialogue objects | |
| float | mContentsScale |
| 内容缩放比例 (pixels / contentsScale = points) Content scale ratio (pixels / contentsScale = points) | |
| CALayer * | mLayer |
| 字幕渲染的父图层 Parent layer for subtitle rendering | |
| float | mVideoDisPlayHeightPoint |
| 视频显示区域高度,单位为点(point) Video display area height in points | |
| float | mVideoDisPlayWidthPoint |
| 视频显示区域宽度,单位为点(point) Video display area width in points | |
VTT subtitle rendering implementation class.
Core rendering engine responsible for subtitle parsing, style application, layout calculation, and display. Supports various features of the WebVTT standard, including styles, positions, regions, etc.
| - (void) actualShow: | (AliVttDialogueObj *) | dialogueObj | |
| withContext: | (RenderContext *) | context |
Actually display subtitle.
| dialogueObj | Subtitle dialogue object |
| context | Rendering context |
| - (void) applyBackgroundColorStyle: | (AliVttDialogueObj *) | dialogueObj | |
| contentAttribute: | (VttContentAttribute *) | contentAttribute |
Apply background color style.
| dialogueObj | Subtitle dialogue object |
| contentAttribute | Content attribute |
| - (void) applyColorStyle: | (NSMutableDictionary *) | attrs | |
| contentAttribute: | (VttContentAttribute *) | contentAttribute |
Apply text color style.
| attrs | Attributes dictionary |
| contentAttribute | Content attribute |
| - (void) applyDecorationStyle: | (NSMutableDictionary *) | attrs | |
| contentAttribute: | (VttContentAttribute *) | contentAttribute |
Apply text decoration styles (underline, strikethrough, etc.)
| attrs | Attributes dictionary |
| contentAttribute | Content attribute |
| - (void) applyFontStyle: | (NSMutableDictionary *) | attrs | |
| contentAttribute: | (VttContentAttribute *) | contentAttribute | |
| context: | (RenderContext *) | context |
Apply font style.
| attrs | Attributes dictionary |
| contentAttribute | Content attribute |
| context | Rendering context |
| - (void) applyLayerSetting: | (AliVttDialogueObj *) | dialogueObj | |
| styleStr: | (NSAttributedString *) | styleStr |
Apply layer settings.
| dialogueObj | Subtitle dialogue object |
| styleStr | Styled text |
| - (void) applyStrokeAndShadow: | (NSMutableDictionary *) | attrs | |
| contentAttribute: | (VttContentAttribute *) | contentAttribute | |
| context: | (RenderContext *) | context |
Apply stroke and shadow effects.
| attrs | Attributes dictionary |
| contentAttribute | Content attribute |
| context | Rendering context |
| - (CGFloat) calculateMaxTextWidth |
Calculate maximum text width.
| - (void) clear |
Clear all subtitle display content.
| - (BOOL) containsFullWidthCharacters: | (NSString *) | string |
Detect if string contains full-width characters.
| string | String to be detected |
| - (BOOL) containsUpperGlyphCharacters: | (NSString *) | string |
Detect if string contains superscript characters.
| string | String to be detected |
| - (NSAttributedString *) createStyledText: | (NSArray< VttContentAttribute * > *) | contentAttributes | |
| dialogueObj: | (AliVttDialogueObj *) | dialogueObj | |
| withContext: | (RenderContext **) | context |
Create styled attributed text.
| contentAttributes | Content attributes array |
| dialogueObj | Subtitle dialogue object |
| context | Double pointer to rendering context |
| - (NSAttributedString *) createStyledTextSegment: | (VttContentAttribute *) | contentAttribute | |
| context: | (RenderContext **) | context |
Create styled string for single text segment.
| contentAttribute | Content attribute |
| context | Double pointer to rendering context |
| - (void) customizeAttribuets: | (NSMutableArray< VttContentAttribute * > *) | contentAttributes | |
| locationAttribute: | (VttLocationAttribute *) | locationAttribute |
Customize content attributes and location information (for subclass override)
| contentAttributes | Array of content attribute objects |
| locationAttribute | Location attribute object |
| - (UIFont *) customizeFont: | (UIFont *) | originalFont | |
| contentAttribute: | (VttContentAttribute *) | contentAttribute | |
| contentText: | (NSString *) | text |
Customize font (for subclass override)
| originalFont | Original font |
| contentAttribute | Content attribute |
| text | Text content |
| - (void) customizeParagraphStyle: | (NSMutableParagraphStyle *) | paragraphStyle | |
| withFont: | (UIFont *) | font | |
| contentText: | (NSString *) | text |
Customize paragraph style (for subclass override)
| paragraphStyle | Paragraph style object |
| font | Font object |
| text | Text content |
| - (AliVttDialogueObj *) findDialogueObjByIdx: | (NSInteger) | index |
Find subtitle dialogue object by index.
| index | Subtitle index |
| - (AliVttDialogueObj *) findIdleDialogueObj |
Find idle subtitle dialogue object.
| - (UIFont *) generateFontWithName: | (NSString *) | fontName | |
| fontSize: | (CGFloat) | fontSize | |
| isBold: | (BOOL) | isBold | |
| isItalic: | (BOOL) | isItalic |
Generate font with specified style.
| fontName | Font name |
| fontSize | Font size |
| isBold | Whether bold |
| isItalic | Whether italic |
| - (void) getActualTextPositions: | (VttLocationAttribute *) | locationAttribute | |
| withContext: | (RenderContext *) | context |
Calculate subtitle display position.
| locationAttribute | Location attribute |
| context | Rendering context |
| - (void) getActualTextSize: | (NSAttributedString *) | styleStr | |
| dialogue: | (AliVttDialogueObj *) | dialogueObj | |
| withContext: | (RenderContext *) | context |
Calculate actual text size.
| styleStr | Styled text string |
| dialogueObj | Subtitle dialogue object |
| context | Rendering context |
| - (UIColor *) getColorFromValue: | (NSInteger) | value |
Create UIColor object from integer value.
| value | Color value in ARGB format |
| - (void) getParentViewSize: | (CGFloat *) | w | |
| h: | (CGFloat *) | h |
Get parent view size.
| w | Width pointer for returning width value |
| h | Height pointer for returning height value |
| - (CGSize) getSizeFromStr: | (NSMutableAttributedString *) | attrStr | |
| withMaxtextWidth: | (CGFloat) | maxTextWidth |
Calculate display size of attributed text.
| attrStr | Attributed text string |
| maxTextWidth | Maximum text width |
| - (nullable AliWebVttHeader *) getVttHeader |
Get VTT header information.
| - (void) hideDialogue: | (NSString *) | data | |
| atIndex: | (int) | index |
Hide subtitle at specified index.
| data | Subtitle data string |
| index | Subtitle index |
| - (void) initialDialogueObj: | (AliVttDialogueObj **) | obj | |
| index: | (NSUInteger) | index |
Initialize subtitle dialogue object.
| obj | Double pointer to dialogue object for returning created or reused object |
| index | Subtitle index |
| - (CGPoint) maybeApplyDefaultPosition: | (CGPoint) | locationPoint | |
| withContext: | (RenderContext *) | context |
Apply default position rules.
| locationPoint | Coordinate point calculated from location attributes |
| context | Rendering context |
| - (CGFloat) maybeForcebeCenter: | (CGFloat) | x | |
| withContext: | (RenderContext *) | context |
Force center alignment (when position is out of range)
| x | X coordinate |
| context | Rendering context |
| - (CGFloat) maybeUpperThanBase: | (CGFloat) | y | |
| withContext: | (RenderContext *) | context |
Ensure position is above baseline.
| y | Y coordinate |
| context | Rendering context |
| - (RenderContext *) prepareRenderContext |
Prepare rendering context.
| - (CGPoint) processAttributePosition: | (VttLocationAttribute *) | locationAttribute | |
| withContext: | (RenderContext *) | context |
Process location attributes and calculate base coordinates.
| locationAttribute | Location attribute |
| context | Rendering context |
| - (CGFloat) processXPositon: | (VttLocationAttribute *) | locationAttribute | |
| withContext: | (RenderContext *) | context |
Process X direction position.
| locationAttribute | Location attribute |
| context | Rendering context |
| - (CGFloat) processYPosition: | (VttLocationAttribute *) | locationAttribute | |
| withContext: | (RenderContext *) | context |
Process Y direction position.
| locationAttribute | Location attribute |
| context | Rendering context |
| - (void) renderSubtitleContent: | (AliVttDialogueObj *) | dialogueObj | |
| contentAttributes: | (NSArray< VttContentAttribute * > *) | contentAttributes | |
| locationAttribute: | (VttLocationAttribute *) | locationAttribute |
Main method for rendering subtitle content.
| dialogueObj | Subtitle dialogue object |
| contentAttributes | Content attributes array |
| locationAttribute | Location attribute |
| - (void) safelyRemoveObserverIfNeeded |
Safely remove observer.
| - (void) setup: | (CALayer *) | view |
Initialize renderer and set parent layer.
| view | CALayer object for displaying subtitles |
| - (void) setVttHeader: | (NSString *) | header |
Set VTT header information.
| header | VTT header string containing style and region definitions |
| - (void) showDialogue: | (NSString *) | data | |
| atIndex: | (int) | index |
Show subtitle at specified index.
| data | Subtitle data string |
| index | Subtitle index |
| - (RenderContext *) updateRenderContext: | (RenderContext *) | context | |
| withSubStr: | (NSAttributedString *) | subAttributedString |
Update rendering context.
| context | Rendering context |
| subAttributedString | Sub attributed string |
| - (void) updateVideoDisPlay: | (int) | videoWidth | |
| height: | (int) | videoHeight | |
| scaleMode: | (AVPScalingMode) | mode |
Update video display information.
| videoWidth | Video width in pixels |
| videoHeight | Video height in pixels |
| mode | Video scaling mode |
|
readwritenonatomicassign |
全局常量类,所有实例共享 Global constant class shared by all instances
|
readwritenonatomicstrong |
管理的字幕对话框对象数组 Array of managed subtitle dialogue objects
|
readwritenonatomicassign |
内容缩放比例 (pixels / contentsScale = points) Content scale ratio (pixels / contentsScale = points)
|
readwritenonatomicstrong |
字幕渲染的父图层 Parent layer for subtitle rendering
|
readwritenonatomicassign |
视频显示区域高度,单位为点(point) Video display area height in points
|
readwritenonatomicassign |
视频显示区域宽度,单位为点(point) Video display area width in points