同步操作将从 CY./RedPlayer 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
This guide provides step-by-step instructions on how to initialize and configure the iOS SDK for our open-source video player. This player supports videos in both regular URL and JSON formats and offers multiple rendering methods, including Metal, OpenGL, and SampleBufferDisplayLayer.
📌Integrate RedPlayer into your Xcode project RedPlayerDemo
📌For video preloading feature, please refer to RedPreload_SDK
For regular URL playback, use:
self.player = [[RedPlayerController alloc] initWithContentURL:[NSURL urlWithString:@"http://xxx.mp4"]; withRenderType:RedRenderTypeMetal/RedRenderTypeOpenGL/RedRenderTypeSampleBufferDisplayLayer];
For JSON formats playback, use:
self.player = [[RedPlayerController alloc] initWithContentURLString:@"" withRenderType:RedRenderTypeMetal/RedRenderTypeOpenGL/RedRenderTypeSampleBufferDisplayLayer];
[self.player setContentString:Json];
[self.player setEnableHDR:YES];
self.player.view.frame = self.view.bounds;
self.player.scalingMode = RedScalingModeAspectFit;
self.player.shouldAutoplay = YES;
self.player.notPauseGlviewBackground = NO;
[self.player setLoop:self.isLoop ? 0 : 1];
[self.player setMute:NO];
[self.player setEnableVTB:YES];
[self.player setLiveMode:YES];
[self.player setVideoCacheDir:[RedMediaUtil cachePath]];
[self.player prepareToPlay];
/// Prepares the media for playback.
- (void)prepareToPlay;
/// Starts playback.
- (void)play;
/// Pauses playback.
- (void)pause;
/// Sets whether to pause in the background.
- (void)setPauseInBackground:(BOOL)pause;
/// Seeks to the specified playback time.
- (BOOL)seekCurrentPlaybackTime:(NSTimeInterval)aCurrentPlaybackTime;
/// Sets the loop setting.
- (void)setLoop:(int)loop;
/// Sets the mute status.
- (void)setMute:(BOOL)muted;
/// Shuts down the media playback. This will release the kernal player object
- (void)shutdown;
/// The current playback time.
@property (nonatomic, assign) NSTimeInterval currentPlaybackTime;
/// The total duration of the media.
@property (nonatomic, readonly) NSTimeInterval duration;
/// The duration of media that can be played without buffering.
@property (nonatomic, readonly) NSTimeInterval playableDuration;
/// Indicates whether the playback is prepared to play.
@property (nonatomic, readonly) BOOL isPreparedToPlay;
/// The current playback state.
@property (nonatomic, readonly) RedPlaybackState playbackState;
/// The current load state.
@property (nonatomic, readonly) RedLoadState loadState;
/// The buffering progress as a percentage.
@property (nonatomic, readonly) NSInteger bufferingProgress;
/// The duration of cached content.
@property (nonatomic, readonly) int64_t cachedDuration;
/// The natural size of the media.
@property (nonatomic, readonly) CGSize naturalSize;
/// The scaling mode for video playback.
@property (nonatomic, assign) RedScalingMode scalingMode;
/// Returns whether the media is currently playing.
- (BOOL)isPlaying;
/// Retrieves the actual playback URL.
- (NSString *)getPlayUrl;
/// Retrieves debug information for video.
- (NSDictionary *)getVideoDebugInfo;
// RedMediaPlaybackIsPreparedToPlayDidChangeNotification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(mediaIsPreparedToPlayDidChange:)
name:RedMediaPlaybackIsPreparedToPlayDidChangeNotification
object:_player];
// RedPlayerFirstVideoFrameRenderedNotification
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveFirstFrameRenderedNotification:)
name:RedPlayerFirstVideoFrameRenderedNotification object:_player];
/// Enum for RedVideoFirstRenderingReason
typedef NS_ENUM(NSInteger,RedVideoFirstRenderingReason){
RedVideoFirstRenderingReasonStart, ///< Start rendering
RedVideoFirstRenderingReasonWaitStart ///< Wait start rendering,
};
// RedPlayerPlaybackStateDidChangeNotification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackStateDidChange:)
name:RedPlayerPlaybackStateDidChangeNotification
object:_player];
/// Enum for RedPlaybackState
typedef NS_ENUM(NSInteger, RedPlaybackState) {
RedPlaybackStateStopped, ///< Playback is stopped
RedPlaybackStatePlaying, ///< Playback is playing
RedPlaybackStatePaused, ///< Playback is paused
RedPlaybackStateInterrupted, ///< Playback is interrupted
RedPlaybackStateSeekingForward, ///< Playback is seeking forward
RedPlaybackStateSeekingBackward ///< Playback is seeking backward
};
// RedPlayerLoadStateDidChangeNotification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(loadStateDidChange:)
name:RedPlayerLoadStateDidChangeNotification
object:_player];
/// Enum for RedLoadState
typedef NS_OPTIONS(NSUInteger, RedLoadState) {
RedLoadStateUnknown = 0, ///< Unknown load state
RedLoadStatePlayable = 1 << 0, ///< State when playable
RedLoadStatePlaythroughOK = 1 << 1, ///< Playback will be automatically started in this state when shouldAutoplay is YES
RedLoadStateStalled = 1 << 2, ///< Playback will be automatically paused in this state, if started
};
// RedPlayerPlaybackDidFinishNotification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:RedPlayerPlaybackDidFinishNotification
object:_player];
/// Enum for RedFinishReason
typedef NS_ENUM(NSInteger, RedFinishReason) {
RedFinishReasonPlaybackEnded, ///< Playback ended
RedFinishReasonPlaybackError, ///< Playback error
RedFinishReasonUserExited ///< User exited
};
Stage-by-stage status callback monitoring - NotificationName
// add observer for event notifacation
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(notificationEvent:)
name:RedPlayerXXXXXXXXXNotification
object:_player];
Cache Finish Callback: Receive a callback when caching is complete.
// RedPlayerCacheDidFinishNotification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayCacheDidFinish:)
name:RedPlayerCacheDidFinishNotification
object:_player];
// RedPlayerUrlChangeMsgNotification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayUrlChangeMsg:)
name:RedPlayerUrlChangeMsgNotification
object:_player];
// RedPlayerNaturalSizeAvailableNotification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieNaturalSizeChange:)
name:RedPlayerNaturalSizeAvailableNotification object:self.player];
/// Callback block for RedLogCallback
typedef void(^RedLogCallback)(RedLogLevel logLevel, NSString *tagInfo, NSString *logContent);
/**
Sets the log callback level for the RedPlayerController.
@param logLevel The log level for the log callback.
*/
+ (void)setLogCallbackLevel:(RedLogLevel)logLevel;
/**
Sets the log callback for the RedPlayerController.
@param logCallback The log callback block.
*/
+ (void)setLogCallback:(RedLogCallback)logCallback;
/**
Sets the log callback for the RedPlayerController with a specific log call scene.
@param logCallback The log callback block.
@param logCallScene The log call scene.
*/
+ (void)setLogCallback:(RedLogCallback)logCallback logCallScene:(REDLogCallScene)logCallScene;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。