tivio_sdk

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

tivio sdk

Tivio Flutter SDK #
Initialize Tivio #


Parameter secret is generated in administration and identifies the application.
Parameter language is language of the application.
Parameter logLevel sets log level of the sdk.
initTivio returns a Tivio instance.

enum TivioLanguages { cs, en, sk, de, pl }
enum TivioLogLevels { verbose, debug, info, warning, error, nothing }

Future<Tivio> initTivio({String secret, TivioLanguages language, TivioLogLevels logLevel});
copied to clipboard
Example of initialization #
import 'package:tivio_sdk/tivio.dart';

class App {
Tivio _tivio;

init () async {
_tivio = await initTivio(secret: 'a18b5f9e-4eb3-4bdb-a69b-660f1cd0d9b9', language: TivioLanguages.cs);
}
}
copied to clipboard
Set user #

Is used for signing in by organization specific provider, for example firebase id token or oAuth
Method decides which provider to use, depending on the organization's configuration

class Tivio {
Future<void> setUser(String userId, dynamic payload, {dynamic additionalUserData});
}
copied to clipboard
Set language #

Can change language after initialization

class Tivio {
Future<void> setLanguage(TivioLanguages language);
}
copied to clipboard
Reactive data #

TivioDataStream #

Wrapper of dart Stream

class TivioDataStream<T> {
Stream<T> get stream;
close();
}
copied to clipboard
Widget #
class Tivio {
TivioDataStream<TivioDataWidget> subscribeToWidget({required String widgetId, int count = 10});
}
copied to clipboard
Channel #
class Tivio {
TivioDataStream<TivioDataPagination<TivioDataChannel>> subscribeToChannelsInWidget({required String widgetId, int count = 10});

fetchNextChannelsInWidget({required String widgetId, int count = 10});

TivioDataStream<TivioDataChannel> subscribeToChannel({required String channelId});
}
copied to clipboard
Section #
class Tivio {
TivioDataStream<TivioDataPagination<TivioDataSection>> subscribeToSectionsInChannel({required String channelId, int count = 10});

fetchNextSectionsInChannel({required String channelId, int count = 10});

TivioDataStream<TivioDataSection> subscribeToSection({required String sectionId});
}
copied to clipboard
Video #
class Tivio {
TivioDataStream<TivioDataPagination<TivioDataVideo>> subscribeToVideosInSection ({required String sectionId, int count = 10});

fetchNextVideosInSection({required String sectionId, int count = 10});

TivioDataStream<TivioDataVideo> subscribeToVideo({required String videoId});
}
copied to clipboard
Recent #
class Tivio {
TivioDataStream<TivioDataPagination<TivioDataVideo>> subscribeToRecentVideosInWidget({required String widgetId, int count = 10});

TivioDataStream<TivioDataPagination<TivioDataVideo>> subscribeToRecentVideosInChannel({required String channelId, int count = 10});
}
copied to clipboard
Screens #
class Tivio {
TivioDataStream<TivioDataScreen>? subscribeToScreen({required String screenId});

TivioDataStream<TivioDataPagination<TivioDataRowItem>>? subscribeToItemsInRow({required String rowId, int count = 10});
}
copied to clipboard
Search #
class Tivio {
Future<TivioDataPagination<TivioDataChannel>> searchChannels({required String query, int limit = 10});

Future<TivioDataPagination<TivioDataVideo>> searchVideos({required String query, int limit = 10});
}
copied to clipboard

DTO #
Pagination #

Result of methods that can return a larger amount of data is wrapped in the Pagination object.
To get all records iterate until the hasNextPage is true.
Called method can have a count parameter to change the number of returned records.

class TivioDataPagination<T> {
List<T> records;
bool hasNextPage;
}
copied to clipboard
Widget #

A widget holds together multiple channels with some specific configuration.

class TivioDataWidget {
String id;
String name;
}
copied to clipboard
Channel #

The Channel is a container for multiple sections.

class _ChannelImages {
String logo;
String cover;
}

class TivioDataChannel {
String id;
String name;
_ChannelImages images;
}
copied to clipboard
Section #

The Section is a container for multiple videos.

class TivioDataSection {
String id;
String name;
}
copied to clipboard
Assets #
class TivioAssetScale {
String? background;
}

class TivioAssets {
TivioAssetScale? small;
TivioAssetScale? medium;
TivioAssetScale? large;
}
copied to clipboard
Video #
class _Url {
String hls;
}

class _VideoImages {
String cover;
}

class _Monetization {
num price;
String type;
}

class TivioDataPlaylistItem {
String name;
_Url url;
Duration duration;
}

class TivioDataVideo {
String id;
String name;
Duration duration;
DateTime created;
bool isPlaylist;
List<TivioDataPlaylistItem> playlistItems;
_Url url;
_VideoImages images;
_Monetization monetization;
Map<String, TivioAssets> assets;
String? description;
}
copied to clipboard
Screen #
class TivioDataScreen {
String id;
String name;
List<TivioDataRow> rows;
Map<String, TivioAssets> assets;
String? description;
}

class TivioDataRow {
String id;
String name;
String itemComponent;
String rowComponent;
Map<String, TivioAssets> assets;
String? description;
}
copied to clipboard
Row #
class TivioDataRowItem {
TivioRowItemType type;
TivioDataVideo? video;
TivioDataTag? tag;
}
copied to clipboard
Tag #
class TivioDataTag {
String type;
String name;
String? description;
Map<String, TivioAssets> assets;
}
copied to clipboard
Video player #
Declarative api #
import 'package:tivio_sdk/tivio.dart';

class App extends StatefulWidget {
@override
_AppState createState() => __AppState();
}

class _AppState extends State<App> {
bool _isTivioInitialized = false;
Tivio _tivio;

@override
void initState() {
super.initState();
initializeTivio();
}

initializeTivio() async {
_tivio = await initTivio('a18b5f9e-4eb3-4bdb-a69b-660f1cd0d9b9');

setState(() {
_isTivioInitialized = true;
});
}

@override
Widget build(BuildContext context) {
return (_isTivioInitialized)
? Column(
children: [
TivioPlayer(
playerId: 'MainPlayer',
tivio: _tivio,
source: TivioDataVideo(
'4PlQ6BE0oPFfMMjqAjsU',
'Episode 1',
Duration(milliseconds: 1200080),
DateTime(2020),
'https://cdn1.tiv.io/video/playlist.m3u8',
'https://cdn1.tiv.io/some-image.jpg',
false,
null,
null,
),
),
],
)
: Text('...');
}
}
copied to clipboard
Imperative api #
import 'package:tivio_sdk/tivio.dart';

class App extends StatefulWidget {
@override
_AppState createState() => __AppState();
}

class _AppState extends State<App> {
bool _isTivioInitialized = false;
Tivio _tivio;
TivioPlayerController _tivioPlayerController;

@override
void initState() {
super.initState();
initializeTivio();
}

initializeTivio() async {
_tivio = await initTivio('a18b5f9e-4eb3-4bdb-a69b-660f1cd0d9b9');
_tivioPlayerController = TivioPlayerController();

setState(() {
_isTivioInitialized = true;
});
}

@override
Widget build(BuildContext context) {
return (_isTivioInitialized)
? Column(
children: [
TivioPlayer(
playerId: 'MainPlayer',
tivio: _tivio,
controller: _tivioPlayerController,
),
Column(
children: [
TextButton(
onPressed: () {
_tivioPlayerController.openAndPlay(
TivioDataVideo(
'4PlQ6BE0oPFfMMjqAjsU',
'Episode 1',
Duration(milliseconds: 1200080),
DateTime(2020),
'https://cdn1.tiv.io/video/playlist.m3u8',
'https://cdn1.tiv.io/some-image.jpg',
false,
null,
null,
),
);
},
child: Text('Play Episode 1'),
),
],
)
],
)
: Text('...');
}
}
copied to clipboard
Api #
TivioPlayer #
class TivioPlayer extends StatefulWidget {
TivioPlayer({
required String this.playerId,
required Tivio this.tivio,
TivioDataVideo tivioVideoSource,
TivioPlayerController tivioPlayerController,
TivioPlayerColors tivioPlayerColors,
bool startInFullscreen = false,
});
}
copied to clipboard
TivioPlayerColors
class TivioPlayerColors {
final Color progressBarPlayed;
}
copied to clipboard
TivioPlayerLayout
enum TivioPlayerLayoutTopLeft {
custom,
}

enum TivioPlayerLayoutTopRight {
custom,
}

enum TivioPlayerLayoutBottomRight {
toggleFullscreen,
}

class TivioPlayerLayout {
final TivioPlayerLayoutTopLeft? topLeft;
final Widget? topLeftCustomWidget;
final TivioPlayerLayoutTopRight? topRight;
final Widget? topRightCustomWidget;
final TivioPlayerLayoutBottomRight? bottomRight = TivioPlayerLayoutBottomRight.toggleFullscreen;
}
copied to clipboard
TivioPlayerController
class TivioPlayerController {
void play ();
void pause ();
void openAndPlay (TivioDataVideo source);
void seekTo (Duration time);
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.