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 below methods you will retrieve contents or sections

Android
iOS
Web
Cordova
Android
class MainActivity : AppCompatActivity() {
private fun getSections() {
STSections.getInstance()?.getSections(object: STHttpCallback<List<STSections>> {
override fun onSuccess(sections: List<STSections>) {
println(sections)
}
override fun onError(error: Throwable) {
println(error)
}
})
}
private fun getContent() {
val contentKey: String = "azeaze-311qsd-qsdaze"
STContents.getInstance()?.getContent(contentKey, object: STHttpCallback<STContent> {
override fun onSuccess(content: STContent) {
println(sections)
}
override fun onError(error: Throwable) {
println(error)
}
})
}
iOS
SampleViewController.swift
import UIKit
import StayTunedSDK
class SampleViewController: UIViewController {
private func getSections() {
STSections.shared?.getSections(completion: { result in
switch result {
case .success(let sections):
print(sections)
case .failure(let error):
print(error)
}
})
}
private func getContent() {
let contentKey: String = "azeaze-311qsd-qsdaze"
STContents.shared?.getContent(by: contentKey, completion: { result in
switch result {
case .success(let contents):
print(contents)
case .failure(let error):
print(error)
}
})
}
}
Web
JS
import '@staytuned-io/sdk'
// List sections
const sectionList = await staytunedSDK.STSections.getSections();
// List contents (will retrieve light contents)
const contentList = await staytunedSDK.STContents.getContents();
// Get one content (get full content)
const content = await staytunedSDK.STContents.getContent('one-content-key');
TS
import '@staytuned-io/sdk'
import { STContentLight } from '@staytuned-io/sdk/dist/types/models/content-light'
import { STContent } from '@staytuned-io/sdk/dist/types/models/content'
import { STSection } from '@staytuned-io/sdk/dist/types/models/section'
// List sections
const sectionList: Array<STSection> = await staytunedSDK.STSections.getSections();
// List contents (will retrieve light contents)
const contentList: Array<STContentLight> = await staytunedSDK.STContents.getContents();
// Get one content (get full content)
const content: STContents = await staytunedSDK.STContents.getContent('one-content-key');
Cordova
import { STSection, STSections, STContentLight , STContent, STContents } from "@staytuned-io/cordova-typescript";
// list all sections
const sections: STSection[] = await STSections.getInstance().getSections();
// list all contents
const contents: STContentLight [] = await STContents.getInstance().getContents();
// get a complete content by its key
const content: STContent = await STContents.getInstance().getContent(contents[0].key);