Integrate the AI Education solution for iOS

Updated at:

The AI Education solution is an end-to-end AI video solution that Alibaba Cloud builds on AliPlayerKit and ApsaraVideo VOD for businesses such as online education, course training, and knowledge distribution. This topic describes how to integrate the solution on iOS, including the prerequisites, the available integration paths, the App Server operations, and the client data models.

Use cases

The AI Education solution uses the player as the unified entry point. ApsaraVideo VOD provides the video content and the supporting services, and the solution adds automated content understanding that generates summaries, chapters, and key points. Viewers see how the content is organized, locate important segments, and review them at any time, so a long video becomes content that they browse on demand instead of watching end to end.

Online courses, vocational training, enterprise learning, paid knowledge, and academic lectures can all use the solution to improve learning efficiency and the viewing experience, make better use of existing video content, and reduce the cost of integrating and building player and AI features.

ai-education-ui-preview

Core capabilities

The AI Education solution provides the following capabilities for quick understanding, precise navigation, and efficient review:

Capability

Description

AI chapters

Automatically identifies the structure of the video content and generates chapters, which appear on the progress bar and in the chapter list at the same time. Click a chapter to jump to the corresponding segment.

Content summary

Provides an overall video summary and chapter summaries, which help viewers quickly understand the main content and the key points of each chapter.

Key point extraction

Automatically extracts the key points of each chapter and displays them in a structured form for learning and review.

Chapter thumbnails

Displays a representative frame for each chapter, which helps viewers identify and locate the content that they want.

Portrait and landscape adaptation

Adjusts the interaction layout based on the screen orientation: the panel appears at the bottom in portrait mode and on the right in landscape mode.

How the AI Education solution works

The AI Education solution consists of the client, the App Server, Intelligent Media Services (ICE) AI workflows, and the ApsaraVideo VOD service.

The end-to-end process has two phases:

  • Production phase — The App Server triggers the AI analysis workflow. ICE retrieves the media asset, extracts chapters, generates summaries, and analyzes key points, and then writes the structured results back to ApsaraVideo VOD.

  • Consumption phase — The client gets the playback credential and the AI analysis results from the App Server, and PlayerKit handles video playback, chapter navigation, and AI content display.

End-to-end business process

The end-to-end business process of the AI Education solution covers the full path of AI analysis results from production and storage to consumption on the client.

In this process, ApsaraVideo VOD stores the media assets and the AI analysis results in a unified way. ICE AI workflows handle content understanding and structured analysis. The App Server encapsulates the server-side capabilities and provides a unified interface to the client.

image

Client interaction process

The client interaction process describes the calls between the client, PlayerKit, and the App Server after the AI Education playback page opens.

When the page initializes, the client gets the playback credential and then the AI analysis results. After the data finishes loading, the chapter content panel shows chapters, summaries, and key points, and viewers can jump to the corresponding position in the video.

image
Note

If the AI analysis request fails or returns an empty result, the client can still use the playback credential to play the video as usual, but the chapter list and the AI analysis panel do not appear.

Client layered architecture

The client of the AI Education solution uses a layered design that consists of the scenario layer, the PlayerKit capability layer, and the Player SDK.

The scenario layer handles page orchestration, data loading, and AI content display. PlayerKit uses slots to provide the entry in the player control bar and the panel extension capabilities. The underlying Player SDK handles media asset playback, progress control, and playback status callbacks.

LayeredArchitecture-iOS

Prerequisites

Complete the following preparations before you integrate the AI Education solution on iOS:

  • Player SDK version — Use ApsaraVideo Player SDK 7.16.0 or later.

  • Podfile dependency — Import the Down dependency (~> 0.11.0) in the Podfile. Markdown rendering in the AI analysis panel depends on it.

  • PlayerKit scenario layer — The AI Education solution is built on the PlayerKit scenario layer, so complete the general integration first: Integration preparation—Scenario layer integration (import the PlayerKit and SceneAiEducation modules), and Quick start—Scenario layer setup (start the scenario page).

  • Alibaba Cloud services — Activate ApsaraVideo VOD in the ApsaraVideo VOD console and activate Intelligent Media Services in the Intelligent Media Services console.

  • Media asset — A test video is ready and AI content analysis for the video is complete.

  • App Server — Deploy an App Server that provides playback credentials and AI analysis data. For an implementation reference, see the VodAppServer open source project.

Choose an integration path

The AI Education solution supports three integration paths. Choose the path that matches how much of the built-in scenario page you reuse:

Integration path

When to use

Built-in scenario page (Recommended)

You want the shortest path to a working page. SceneAiEducationViewController provides the page and loads data through AiContentLoader, so you only configure the App Server URL and the media asset ID.

Replace the data source

You keep the built-in loading flow but get playback credentials and AI analysis data from your own data source.

Integrate into an existing view controller

You do not want to use the built-in SceneAiEducationViewController, and you orchestrate the player, the data loading, and the chapter button slot in your own view controller.

Integrate with the built-in scenario page

After the general integration of the PlayerKit scenario layer is complete, the AI Education solution requires only the following configuration.

Configure the App Server and the test video

Open AiContentConstants.m and modify the following constants:

NSString * const AiContentAppServerBaseURL = @"http://your-server-host:port";

NSString * const AiContentDefaultMediaId = @"your-media-id";

Set AiContentAppServerBaseURL to the base URL of the App Server that you deployed, and set AiContentDefaultMediaId to the ID of the media asset that you use for testing.

Start the scenario page

Start the AI Education page with the scenario layer setup method. The following table lists the view controller and the URL scheme that identify the page.

Item

Value

View controller

SceneAiEducationViewController

URL scheme

playerkit://scenes/aieducation

Verify the integration

After the page starts, the video loads automatically and the player displays the chapter entry button. Click the button to view the chapter list and the AI analysis content. If both appear, the integration is successful.

If the video plays but the chapter entry button or the AI analysis content does not appear, see Integration FAQ.

Replace the data source

By default, SceneAiEducationViewController loads data through AiContentLoader. To use your own data source, refer to the implementation flow of the view controller and replace the data loading logic. Load the playback credential first, and then load the AI analysis content in the completion block:

// Sample custom loading
AiContentLoader *loader = [[AiContentLoader alloc] initWithBaseURL:@"http://your-server"];
[loader loadPlayAuthWithVideoId:@"your-vid"
                     completion:^(NSString * _Nullable playAuth) {
    // After you get playAuth, continue to load the AI content...
    [loader loadAiAnalysisWithMediaId:@"your-vid"
                          completion:^(AiAnalysisResponse * _Nullable response) {
        // After you get AiAnalysisResponse, configure the player...
    }];
}];

Both the connection timeout and the read timeout of AiContentLoader are 5 seconds. To use different values, implement a custom loader.

Integrate into an existing view controller

If you do not want to use the built-in SceneAiEducationViewController, refer to its implementation and orchestrate the page yourself:

  • 1. Create the player components — Initialize AliPlayerView and AliPlayerController.

  • 2. Configure the playback source — Create the video source and set AliPlayerModel.sceneType to SceneTypeAIVod.

  • 3. Assemble the AI analysis data — Load the playback credential and the AI analysis data, and then set AliPlayerModel.chapters to the chapter list of the assembled view model.

  • 4. Register the chapter button custom slot — Register ChapterButtonSlot through the slot manager of the player view.

  • 5. Configure and attach the player — Playback starts automatically after the player is attached.

    In the following sample, mediaId is the ID of the media asset, playAuth is the playback credential, and response is the AiAnalysisResponse object. Load playAuth and response from the App Server as described in Replace the data source. The order value in the slot registration is a sample value.

// 1. Create the player components
AliPlayerView *playerView = [[AliPlayerView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:playerView];

AliPlayerController *playerController = [[AliPlayerController alloc] init];

// 2. Configure the playback source by using VidAuth
VideoSource *source = [VideoSource vidAuthSourceWithVid:mediaId playAuth:playAuth];
AliPlayerModel *model = [[AliPlayerModel alloc] initWithVideoSource:source];
model.sceneType = SceneTypeAIVod;

// 3. Assemble the AI analysis response and pass the chapter list to the player
AiContentViewModel *viewModel = [AiContentAssembler buildViewModelFromResponse:response];
model.chapters = viewModel.chapters;

// 4. Register the chapter button custom slot
CustomSlotType *slotType = [CustomSlotType typeWithKey:@"chapter_button" order:85];
[playerView.slotManager registerCustomSlotType:slotType
                                      provider:^UIView<SlotProtocol> *(UIView *parentView) {
    return [[ChapterButtonSlot alloc] initWithFrame:parentView.bounds];
}];

// 5. Configure and attach the player. Playback starts automatically after the player is attached.
[playerController configure:model];
[playerView attach:playerController];

Customize the UI

  • Panel style — To replace the style of the chapter content panel, inherit ChapterContentView and customize the layout.

  • Slots — To extend the player controls, register custom slots through SlotManager.

  • For more information, see Slot system.

App Server operations

The AI Education solution consumes two App Server operations: one returns the playback credential, and one returns the AI analysis content of the media asset.

Get a playback credential

GET {AppServerBaseURL}/appServer/GetVideoPlayAuth?videoId={vid}

Request parameters:

Parameter

Type

Required

Description

videoId

String

Yes

The ID of the video

Sample response:

{
  "code": 0,
  "success": true,
  "data": {
    "videoId": "your-video-id",
    "playAuth": "eyJ..."
  }
}

Response fields:

Field

Type

Description

code

Integer

The business return code. A value of 0 indicates success

success

Boolean

Indicates whether the request was successful

data.videoId

String

The ID of the video

data.playAuth

String

The Base64-encoded playback credential, which expires after a period of time

Get AI analysis content

GET {AppServerBaseURL}/GetMediaAiAnalysisByResultType?MediaId={vid}

To return only one type of result, add the optional ResultType parameter:

GET {AppServerBaseURL}/GetMediaAiAnalysisByResultType?MediaId={vid}&ResultType=Chapter

Request parameters:

Parameter

Type

Required

Description

MediaId

String

Yes

The ID of the media asset

ResultType

String

No

The type of the result: Chapter (chapters) or Summary (summary). If you leave this parameter empty, all results are returned

Sample response:

{
  "AiAnalysisResult": [
    {
      "ResultType": "Chapter",
      "Title": "Video title",
      "Extra": "{\"Summary\":\"Fallback summary text\"}",
      "ChapterContentItems": [
        {
          "ChapterId": "1",
          "StartTime": 0,
          "EndTime": 120000,
          "ChapterTitle": "Course overview",
          "Summary": "This chapter introduces the overall content of the course...",
          "ThumbnailUrl": "https://example.com/thumb1.jpg",
          "KnowledgePoints": [
            {
              "PointId": "1",
              "Point": "Core concept",
              "PointDescription": "A detailed description of the core concept in this chapter..."
            }
          ]
        }
      ]
    },
    {
      "ResultType": "Summary",
      "Title": "Video title",
      "SummaryContent": {
        "ParagraphSummary": "An overall summary of the video content...",
        "MarkdownContent": "# Chapter title\nDetailed content...",
        "MindMapSummary": [
          {
            "Title": "Topic branch",
            "Topic": ["Subtopic A", "Subtopic B"]
          }
        ]
      },
      "Tags": ["Education", "Technology"]
    }
  ]
}

To connect your own server, return the same JSON structure. The client does not depend on how the server is implemented.

The AiAnalysisResult array contains one item per result type. The following tables describe the fields of the Chapter item and the Summary item.

Chapter fields:

Field

Type

Description

ChapterId

String

The unique identifier of the chapter

StartTime

Integer

The start time of the chapter, in milliseconds

EndTime

Integer

The end time of the chapter, in milliseconds

ChapterTitle

String

The title of the chapter

Summary

String

The summary of the chapter

ThumbnailUrl

String

The URL of the chapter thumbnail

KnowledgePoints

Array

The list of key points

KnowledgePoints[].PointId

String

The ID of the key point

KnowledgePoints[].Point

String

The name of the key point

KnowledgePoints[].PointDescription

String

The description of the key point

Summary fields:

Field

Type

Description

SummaryContent.ParagraphSummary

String

The overall paragraph summary of the video

SummaryContent.MarkdownContent

String

The complete analysis content in Markdown

SummaryContent.MindMapSummary

Array

The list of mind map branches. Each item contains Title (String) and Topic (Array<String>)

Tags

Array<String>

The list of video tags

Data models and mappings

Data mapping

The server-side JSON of the AI Education solution maps directly to a data transfer object (DTO) through AiAnalysisResponse, and AiContentAssembler then assembles the DTO into business models. The following table describes how server-side fields map to client DTOs and business models:

Server-side JSON field

Client DTO

Business model

Description

ChapterId

ChapterContentItem.chapterId

ChapterInfo.chapterId

The chapter ID

StartTime

ChapterContentItem.startTime

ChapterInfo.startMs

In milliseconds

EndTime

ChapterContentItem.endTime

ChapterInfo.endMs

In milliseconds

ChapterTitle

ChapterContentItem.chapterTitle

ChapterInfo.title

The chapter title

ThumbnailUrl

ChapterContentItem.thumbnailUrl

ChapterInfo.thumbnailUrl

The thumbnail

Summary

ChapterContentItem.summary

—

The chapter summary. Retained in the DTO

KnowledgePoints[]

ChapterContentItem.knowledgePoints

KnowledgeInfo.contentMarkdown

The list of key points. AiContentAssembler formats the points into the Markdown content of KnowledgeInfo, which the panel reads from AiContentViewModel.knowledgeItems

ParagraphSummary

SummaryContent.paragraphSummary

SummaryInfo.paragraphSummary

The global summary of the video

MarkdownContent

SummaryContent.markdownContent

SummaryInfo.markdownContent

The complete analysis content in Markdown

MindMapSummary[]

SummaryContent.mindMapSummary

SummaryInfo.mindMapItems

Retains the complete MindMapItem structure, including title and topics

Aggregated model

The data is finally aggregated into AiAnalysisResponse, which contains the following fields:

Field

Type

Description

mediaId

NSString *

The ID of the media asset

aiAnalysisResult

NSArray<ResultItem *> *

The list of AI analysis results

chapterResult

ResultItem *

The result item of the Chapter type, provided for convenient lookup by iterating the list and matching the Chapter type

summaryResult

ResultItem *

The result item of the Summary type, provided for convenient lookup by iterating the list and matching the Summary type

Additional information about the DTO models:

  • SummaryContent contains three properties: paragraphSummary (NSString, the paragraph summary), markdownContent (NSString, the complete analysis in Markdown), and mindMapSummary (NSArray<MindMapItem *>, the list of mind map branches).

  • MindMapItem model: title (NSString, the title of the mind map node) and topics (NSArray<NSString *>, the list of subtopics).

    Which result items AiAnalysisResponse carries also determines the layout of the chapter content panel. For details, see Client models and panel rendering.

Client models and panel rendering

The client data architecture of the AI Education solution separates data assembly from UI rendering.

Data flow:

Server JSON → AiAnalysisResponse (DTO) → AiContentAssembler → AiContentViewModel → ChapterContentView (UI)

Client models:

Class

Responsibility

Key properties

AiContentAssembler

Data assembly: converts the DTO into a view model

+buildViewModelFromResponse:

AiContentViewModel

The UI view model and the only data entry point for the panel

chapters, knowledgeItems, summaryInfo, hasChapterData, hasSummaryData

KnowledgeInfo

The chapter display model for TextAnalysis

title, startMs, endMs, contentMarkdown, which is preformatted as - **Point** followed by a full-width colon (U+FF1A) and Description

SummaryInfo

The summary display model for GraphicAnalysis

paragraphSummary, mindMapItems, markdownContent

Design principles:

  • AiAnalysisResponse remains a pure DTO that maps directly to the server-side JSON.

  • AiContentAssembler handles all data assembly, including formatting, extraction, and conversion.

  • ChapterContentView is initialized through initWithViewModel: and only renders data without processing it.

  • AiContentAssembler preformats the rendering format of key points as - **{Point}** followed by a full-width colon (U+FF1A) and {Description}.

    Tab combination rules: the layout of the chapter content panel depends on the data that actually exists in AiAnalysisResponse, and each tab maps to one result item. AiContentViewModel exposes the availability of the two result items as hasChapterData and hasSummaryData, which correspond to chapterResult and summaryResult. The following table describes the panel layout for each combination of available data:

Available data

Panel layout

Rendered content

Only hasChapterData

Two tabs: the chapter tab and the AI analysis tab

The chapter tab renders chapters. The AI analysis tab renders TextAnalysis content, which AiContentAssembler builds from the chapter key points in knowledgeItems

Only hasSummaryData

One AI analysis view without a tab bar

The view renders GraphicAnalysis content: the overall summary, tags, and Markdown content

Both hasChapterData and hasSummaryData

Two tabs: the chapter tab and the AI analysis tab

The chapter tab renders chapters. The AI analysis tab renders GraphicAnalysis content

Integration FAQ

Issue

Solution

Failed to get the playback credential

Check whether the App Server URL is correct, whether the network is connected, and whether the VideoId is valid

The AI content is empty

Make sure that AI analysis is enabled for the video. If no AI data is available, the client falls back to normal playback mode without the AI panel

How do I use my own video ID

Modify AiContentDefaultMediaId in AiContentConstants.m

The panel behaves incorrectly when the screen orientation changes

The panel uses FullscreenTransition.isInFullscreen to determine the current state. Make sure that the view controller supports multiple orientations

How do I disable an AI capability

Do not return the corresponding ResultType in the App Server operation

SDK version compatibility

Check the Player SDK version against the version requirement in Prerequisites

Markdown rendering is abnormal

Make sure that the Podfile imports the Down dependency version listed in Prerequisites

The chapter button does not appear

Make sure that the chapters list of the AiContentViewModel that AiContentAssembler builds is not empty. ChapterButtonSlot controls its visibility based on the availability of chapter data

Network timeout

Both the connection timeout and the read timeout of AiContentLoader are 5 seconds. You can adjust them by using a custom loader