The superplayer SDK for iOS is a player component used to play back videos in VOD. It can implement powerful playback functionality similar to Tencent Video with just a few lines of code.
The superplayer SDK supports more formats and has better compatibility and functionality than system-default players. In addition, it features instant playback on splash screen and low latency.
The VOD superplayer SDK for iOS can be downloaded here.
Add the following code to your Podfile:
pod install or
pod update on the command line to perform the installation.
Log in to the VOD Console, click Media Assets on the left sidebar, and you will see the uploaded video and its corresponding ID (i.e.,
FileId) in the video list in the Uploaded column. If you don't have a video, please click Upload Video to upload one.
You can initiate an adaptive bitrate streaming task for the uploaded video through ProcessMedia:
You are recommended to enter 10 for
MediaProcessTask.AdaptiveDynamicStreamingTaskSet.Definition in the API parameter, indicating transcoding to adaptive bitstream in HLS format.
The main class of the player is
SuperPlayerView, and videos can be played back after it is created.
// Import the header file #import <SuperPlayer/SuperPlayer.h> _playerView = [[SuperPlayerView alloc] init]; // Set the delegate to accept events _playerView.delegate = self; // Set the parent View; `_playerView` will be automatically added under `holderView` _playerView.fatherView = self.holderView; SuperPlayerModel *playerModel = [[SuperPlayerModel alloc] init]; SuperPlayerVideoId *video = [[SuperPlayerVideoId alloc] init]; // Set the playback information video.appId = 1256993030; //AppId video.fileId = @"7447398157015849771"; // Video `FileId` video.playDefinition = @"10"; // Playback template ID video.version = FileIdV3; playerModel.videoId = video; // Start playback [_playerView playWithModel:self.playerModel];
In the code,
appId is your AppId,
fileId is the ID of the video you want to play back,
playDefinition is the ID of the playback template used for playback, and
version is fixed to
Run the code and you can see that the video is played back on the phone and most of the features in the UI are available.
When videos are played back, the "thumbnails" and "timestamps" on the progress bar can help viewers find the points of interest easily. Thumbnails are implemented through image sprites, while timestamps by modifying timestamp information in media assets.
After image sprites are generated and timestamps are added, new elements will be displayed in the player UI.
A small window is a player that floats over the main window within the application. Small window playback is very simple. You just need to call the following code in the appropriate position:
[// Set the player for small window playback [ ].backController = self; // Set the returned view controller [ ] show]; // Floating display].superPlayer = _playerView;
If the player is no longer needed, please call
resetPlayer to clear the internal state of the player and free up the memory.
To try out the complete features, scan the QR code below to download the Tencent Video Cloud toolkit or run the project demo directly.