Retrieve your contents
In this section, we explain how to retrieve contents that you put within our platform.

Content organization

Your audio contents are organized around 3 parts :
  • track : tracks are the audio elements you play.
  • content : we call content a group of tracks that are related to a same show or program. For example a podcast or audiobook is considered as a content.
  • section : a section is a group of contents that you can create on the StayTuned CMS. You can create as many sections as you want to display in your app. A same content can be in different sections.
After calling one of these methods below you will retrieve contents or sections
Android
iOS
Web
Cordova
1
class MainActivity : AppCompatActivity() {
2
3
private fun getSections() {
4
STSections.getInstance()?.getSections(object: STHttpCallback<List<STSections>> {
5
override fun onSuccess(sections: List<STSections>) {
6
println(sections)
7
}
8
9
override fun onError(t: Throwable) {
10
Log.e(LOG_TAG, "Error getting sections", t)
11
}
12
})
13
}
14
15
private fun getContent() {
16
val contentKey: String = "azeaze-311qsd-qsdaze"
17
STContents.getInstance()?.getContent(contentKey, object: STHttpCallback<STContent> {
18
override fun onSuccess(content: STContent) {
19
println(sections)
20
}
21
22
override fun onError(t: Throwable) {
23
Log.e(LOG_TAG, "Error getting content with contentKey : $contentKey", t)
24
}
25
})
26
27
}
28
29
private const val LOG_TAG = "MainActivity"
30
Copied!
SampleViewController.swift
1
import UIKit
2
import StayTunedSDK
3
4
class SampleViewController: UIViewController {
5
6
private func getSections() {
7
STSections.shared?.getSections(completion: { result in
8
switch result {
9
case .success(let sections):
10
print(sections)
11
case .failure(let error):
12
print(error)
13
}
14
})
15
}
16
17
private func getContent() {
18
let contentKey: String = "azeaze-311qsd-qsdaze"
19
STContents.shared?.getContent(by: contentKey, completion: { result in
20
switch result {
21
case .success(let contents):
22
print(contents)
23
case .failure(let error):
24
print(error)
25
}
26
})
27
}
28
29
}
Copied!
JS
1
import '@staytuned-io/sdk'
2
3
// List sections
4
const sectionList = await staytunedSDK.STSections.getSections();
5
6
// List contents (will retrieve light contents)
7
const contentList = await staytunedSDK.STContents.getContents();
8
9
// Get one content (get full content)
10
const content = await staytunedSDK.STContents.getContent('one-content-key');
Copied!
TS
1
import '@staytuned-io/sdk'
2
import { STContentLight } from '@staytuned-io/sdk/dist/types/models/content-light'
3
import { STContent } from '@staytuned-io/sdk/dist/types/models/content'
4
import { STSection } from '@staytuned-io/sdk/dist/types/models/section'
5
6
// List sections
7
const sectionList: Array<STSection> = await staytunedSDK.STSections.getSections();
8
9
// List contents (will retrieve light contents)
10
const contentList: Array<STContentLight> = await staytunedSDK.STContents.getContents();
11
12
// Get one content (get full content)
13
const content: STContent = await staytunedSDK.STContents.getContent('one-content-key');
Copied!
1
import { STSection, STSections, STContentLight , STContent, STContents } from "@staytuned-io/cordova-typescript";
2
3
// list all sections
4
const sections: STSection[] = await STSections.getInstance().getSections();
5
// list all contents
6
const contents: STContentLight [] = await STContents.getInstance().getContents();
7
// get a complete content by its key
8
const content: STContent = await STContents.getInstance().getContent(contents[0].key);
9
Copied!
Copy link