Skip to main content

Teyuto Flutter Player Analytics SDK

Important

If you are using the Teyuto Player, you do not need to integrate this SDK. Analytics tracking is already built into the Teyuto Player.

A Flutter package for integrating video playback analytics with the Teyuto platform, specifically designed to work with Flutter's official video_player package.

Features

  • Seamless integration with Flutter's video_player package
  • Automatic reporting of playback progress in Teyuto
  • Easy-to-use API for Flutter developers
  • Support for both authenticated and unauthenticated usage

Prerequisites

This package requires the video_player package. Make sure to add it to your pubspec.yaml:

dependencies:
video_player: ^2.7.2

Installation

Add teyuto_player_analytics to your pubspec.yaml:

dependencies:
teyuto_player_analytics: ^1.0.0

Run flutter pub get to install the package.

Usage

Here's a basic example of how to use the Teyuto Player Analytics package:

import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
import 'package:teyuto_player_analytics/teyuto_player_analytics.dart';

class VideoPlayerScreen extends StatefulWidget {
@override
_VideoPlayerScreenState createState() => _VideoPlayerScreenState();
}

class _VideoPlayerScreenState extends State<VideoPlayerScreen> {
late VideoPlayerController _controller;
late TeyutoPlayerAnalyticsAdapter _analytics;

@override
void initState() {
super.initState();
_controller = VideoPlayerController.network('https://example.com/video.mp4')
..initialize().then((_) {
setState(() {});
});

// Initialize with a token (for authenticated use)
_analytics = TeyutoPlayerAnalyticsAdapter('channel_public', 'user_auth_token');

// Or initialize without a token (for unauthenticated use)
// _analytics = TeyutoPlayerAnalyticsAdapter('your_channel_id', null);

_analytics.init(_controller, 'video_id');
}

@override
Widget build(BuildContext context) {
return VideoPlayer(_controller);
}

@override
void dispose() {
_controller.dispose();
_analytics.destroy();
super.dispose();
}
}

Important Notes

  • The channel parameter is required and represents your Teyuto channel identifier.
  • The token parameter is optional and represents the token of the user you want to track. This allows you to associate the viewing analytics with a specific user in your system.
  • If you don't provide a token, the analytics will still be tracked, but without user-specific information.

Troubleshooting

If analytics data isn't appearing:

  1. Check console for errors.
  2. Verify that you've provided a valid channel identifier.
  3. If using user tracking, verify the user token.
  4. Ensure the video ID is correct.
  5. Verify that player events (play, pause, ended) are triggering correctly.