Getting Started
This section explains the basics of how to use the .NET/C# SDK component of Lura Player for Tizen. This SDK can be used to enhance the functionality of your video embeds or to implement rich video interactions on Tizen-based Smart TVs.
To get started, copy the following code in your Tizen .NET application and start exploring.
Basic Setup
using Lura;
using Lura.Unified;
using Tizen.NUI;
// Initialize the player
Window window = Window.Instance;
var player = new Player(window);
// Configure the player
var config = new Configuration
{
Lura = new LuraConfiguration
{
AppKey = "your-app-key",
AssetId = "your-asset-id",
}
};
// Set the configuration
await player.SetConfig(config);
// Start playback
player.Play();
Player Controls
// Play/Pause
player.Play();
player.Pause();
// Seek
player.Seek(30.0); // Seek to 30 seconds
// Volume control
player.SetVolume(0.5); // Set volume to 50%
var volume = player.GetVolume();
// Mute/Unmute
player.SetMuted(true);
var isMuted = player.IsMuted();
// Playback speed
player.SetPlaybackSpeed(1.5); // 1.5x speed
var speed = player.GetPlaybackSpeed();
// Get current time and duration
var currentTime = player.GetCurrentTime();
var duration = player.GetDuration();
// Check player state
var isPlaying = player.IsPlaying();
var isPaused = player.IsPaused();
Event Handling
// Subscribe to player events
var listenerId = player.AddListener((@event) =>
{
switch (@event.Type)
{
case UnifiedEventName.PLAYING:
Console.WriteLine("Player started playing");
break;
case UnifiedEventName.PAUSED:
Console.WriteLine("Player paused");
break;
case UnifiedEventName.ENDED:
Console.WriteLine("Playback ended");
break;
case UnifiedEventName.ERROR:
Console.WriteLine($"Error: {@event.Data}");
break;
case UnifiedEventName.TIME_UPDATED:
Console.WriteLine($"Time updated: {@event.Data}");
break;
}
});
// Remove listener when done
player.RemoveListener(listenerId);
Configuration with Manual Content
var config = new Configuration
{
Content = new ContentConfiguration
{
Media = new List<ContentMedia>
{
new ContentMedia
{
Url = "https://example.com/video.mpd",
Type = MediaMimeType.VideoDash
}
},
Title = "My Video",
Description = "Video description"
},
Controls = new ControlsConfiguration
{
Enabled = true,
Autoplay = false,
Muted = false,
Volume = 1.0f
}
};
await player.SetConfig(config);
Subtitle Management
// Enable captions
player.DisplayCaptions(true);
// Get available subtitle tracks
var subtitleTracks = player.GetSubtitleTracks();
// Get active subtitle track index
var activeTrackIndex = player.GetActiveSubtitleTrackIndex();
// Select a subtitle track
player.SelectSubtitleTrack(0); // Select first track
// Disable captions
player.DisplayCaptions(false);
Capabilities
// Get player capabilities
var capabilities = player.GetCapabilities();
Console.WriteLine($"Supports Ads: {capabilities.SupportsAds}");
Console.WriteLine($"Supports Fullscreen: {capabilities.SupportsFullscreen}");
Console.WriteLine($"Supports PiP: {capabilities.SupportsPictureInPicture}");
Console.WriteLine($"Supports Casting: {capabilities.SupportsCasting}");
Console.WriteLine($"Supports Autoplay: {capabilities.SupportsAutoplay}");
Cleanup
// Clear player and release resources
player.Clear();
// Destroy player when done
player.Destroy();