Free Core now2sdk v0.2.2 Core is free for commercial use with zero license key required
Docs Hub SDK Modules Release Notes Pricing Contact GitHub
Download Free SDK →
Source Licensed Add-on Module Summary →

LPlaylist Reference Manual & Seamless Playout Guide

Header#include "LPlaylist.h"
HierarchyLObject, LSink (Dual A/B Playlist)
LicenseLicensed Add-on
TargetsLinux x64 · Win64 · C++17 / .NET

The LPlaylist class is the enterprise-grade automated playout engine of the now2sdk framework. Designed as a drop-in architectural replacement for legacy Medialooks MPlaylist systems (such as VB.NET and C# Playout software like Next4Play), LPlaylist guarantees zero-gap / zero-blink seamless transitions between broadcast video files of mixed formats, framerates, codecs, and resolutions.

Inheriting from both LObject (audio/video master stream source) and LSink (internal sub-engine consumer), LPlaylist internally orchestrates a dual A/B playback pipeline with automated pre-roll, wall-clock broadcast scheduling, multi-channel discrete audio routing, and real-time licensing enforcement.


1. Dual-Engine A/B Architecture & Zero-Blink Guarantee

In traditional file players, opening a new file causes a hardware or decoder reset, resulting in a black frame, dropped frames, or video flicker. LPlaylist eliminates this problem using an internal A/B Dual-Engine Pipeline:

graph TD
        A[Playlist Items Queue] -->|Next clip metadata| B{Scheduler & Monitor}
        
        subgraph sg_1["Sub-Engine A (LFile)"]
            EA[Active Decoder: Clip 1] -->|Video & Audio Frames| SW[Engine Switcher]
        end

        subgraph sg_2["Sub-Engine B (LFile)"]
            EB[Pre-roll Decoder: Clip 2] -.->|Pause on Frame 1| SW
        end

        B -->|2.5s before end of Clip 1| EB
        B -->|Clip 1 reaches Out point| SW
        
        SW -->|Continuous Frame Flow| LIC{Licensed?}
        LIC -->|No| WM[Demo Watermark Overlay]
        LIC -->|Yes| OUT[distributeVideoFrame / distributeAudioFrame]
        WM --> OUT
        
        OUT --> SNK1[LPreview Window]
        OUT --> SNK2[LOutput SDI / DeckLink / NDI]
        OUT --> SNK3[LMixer / LRecorder]

Key Architecture Highlights:


2. Wall-Clock Scheduling & Overdue Tolerances

Items in LPlaylist can be scheduled to trigger at precise times of day using ItemTimesSet.


3. Licensing & Watermark Enforcement

LPlaylist requires an authorized license from now2sdk::LLicenseManager:


4. API Reference

LItem Class Reference

Represents a single media clip, live source, command, or sub-playlist item within the playlist.

void fileNameGet(std::string& path);

Returns the file path, network URL, or command string.

void fileNameSet(const std::string& path);

Sets or changes the media file path or stream URL.

void fileInOutGet(double& inSec, double& outSec, double& durationSec);

Retrieves the In-point, Out-point, and physical media file duration in seconds.

void fileInOutSet(double inSec, double outSec);

Sets the In and Out playback boundary markers (in seconds).

void filePosSet(double posSec, double extraSec = 0.0);

Sets the current playhead position within this item.

void itemTimesGet(std::string& startTime, std::string& stopTime, int& startType);

Retrieves scheduled wall-clock trigger times (format: HH:MM:SS).

void itemTimesSet(const std::string& startTime, const std::string& stopTime, int startType = 0);

Configures scheduled start time. Use "00:00:00" to disable scheduling.

void itemTypeGet(int& type);

Returns item type: 0: File, 1: Command, 2: Live, 3: Playlist.

void itemPlayTimeGet(double& playTimeSec);

Retrieves the active playback duration (outSec - inSec) in seconds.

void formatVideoGet(videoFormatProps& props, std::string& formatStr);

Probes media via LReader and returns properties and string (e.g. "[email protected]").

void formatAudioGet(audioFormatProps& props, std::string& formatStr);

Returns detected audio properties, channel layout, and sample rate.

void propsSet(const std::string& key, const std::string& value);
void propsGet(const std::string& key, std::string& value);

Sets or retrieves custom item metadata (e.g. "skip", "audio_track").


LPlaylist Class Reference

Licensing

bool setLicense(const std::string& key);
bool isLicensed() const;

Initializes and queries license status for "LPlaylist" module.

Playlist Management

int playlistAdd(LItem* pTargetItem, const std::string& path, const std::string& props, int index, LItem** ppItem);

Adds a file, live stream, or sub-playlist to the playlist queue. Returns total item count.

Item Queries

int playlistGetCount(int& count, double& totalDuration);
int playlistGetByIndex(int index, double& pos, std::string& path, LItem** ppItem);

Queries total item count and cumulative duration. Retrieves item handle and cumulative position by index. Note: Passing index = -1 returns the currently playing item.

Playout Head & Current Item

int playlistPosGet(int& curIdx, int& nextIdx, double& filePos, double& listPos);
int playlistPosSet(int index, double filePosSec, double extraSec = 0.0);
int playlistCurrentGet(int& curIdx, double& filePos, double& listPos, std::string& path, LItem** ppItem);
LItem* currentItemGet();

Retrieves active/next clip index, current clip second, and cumulative rundown second. Jumps immediately to index and offset. Retrieves currently playing clip handle and metadata directly.

Queue Editing

int playlistRemoveByIndex(int index, int count = 1);
int playlistReorder(int fromIndex, int delta);
void clear();

Removes items, shifts item positions up/down in rundown, or clears entire playlist.

Commands

int playlistCommandAdd(const std::string& cmd, const std::string& param, const std::string& extra, int index, LItem** ppItem);

Inserts automation command items ("stop", "pause", "pause_last", "loop").

Background

int playlistBackgroundSet(const std::string& path, const std::string& color, const std::string& props, LItem** ppItem);

Configures fallback background image or solid color when playlist is empty or stopped.

State

int fileStateGet(int& status, double& remainingSec);

Returns engine status (0: Stopped, 1: Playing, 2: Paused) and remaining clip seconds.

Transport

bool play();
void pause();
void resume();
void stop();

Primary transport controls.

Properties

void setProps(const std::string& key, const std::string& value);
void getProps(const std::string& key, std::string& value);

Configures or queries runtime playlist engine options (see Section 5).

Format & Normalization

void setVideoFormat(const videoFormatProps& props);
void getVideoFormat(videoFormatProps& props);
void setAudioFormat(const audioFormatProps& props);
void getAudioFormat(audioFormatProps& props);

Configures or retrieves output broadcast resolution (e.g. 1080i50, 1080p59.94, 2160p50) and discrete audio channel layout.


5. Properties & Configuration Options

Configure internal engine behavior dynamically via setProps(key, value):

KeyValue TypeDefault ValueDescription
init_nextbool"true"Enables A/B dual-engine pre-roll ("true" = enabled, "false" = disabled). Pre-rolls next clip 2.5s before active clip ends.
loopbool"true"When "true", automatically restarts playback from index 0 after the last item finishes.
auto_skipbool"true"If a scheduled clip's start time arrives late by more than its own duration, it is automatically skipped.
schedule_wait_startstring"pause-out"Playout behavior while waiting for a scheduled event start time ("pause-out", "stop").
audio_trackint0Specifies the default audio stream index to decode when files contain multiple discrete audio tracks.
last_framebool"true"Holds and repeats the last frame on stop/pause to prevent black blinks on downstream SDI/NDI devices.
logbool"false"Enables file logging for playout operations, engine switches, pre-roll events, and scheduling triggers.
log_pathstring"./logs/"Directory path where log files will be written. Supports ~ for user home directory.
log_namestring"LPlaylist"Module / Channel identifier tag shown in log entries.
log_filestring"sdk_app"Base name for daily rotating log files (format: baseName_YYYY-MM-DD.log).
namestring""Sets friendly channel or instance name for identification and logging.

6. C++ Implementation Example

The following example initializes LPlaylist, sets up DeckLink SDI output with local UI preview, adds media clips with In/Out points, inserts a stop command, and starts broadcast playout:

#include "LPlaylist.h"
#include "LPreview.h"
#include "LOutput.h"
#include <iostream>

int main() {
    // 1. Instantiate LPlaylist and verify licensing
    LPlaylist* playlist = new LPlaylist();
    playlist->setLicense("YOUR-NOW2SDK-LICENSE-KEY");

    if (!playlist->isLicensed()) {
        std::cout << "[NOTICE] LPlaylist is running in trial mode with watermark." << std::endl;
    }

    // 2. Configure Broadcast Output Format (1080i50 European Standard)
    videoFormatProps vProps;
    vProps.setVideoFormat = vF::HD1080_50i;
    playlist->setVideoFormat(vProps);

    audioFormatProps aProps;
    aProps.setAudioFormat = aF::_16B_48K_8CH; // 8-channel SDI discrete audio
    playlist->setAudioFormat(aProps);

    // 3. Connect Sinks (Hardware SDI Output + UI Preview)
    LPreview* preview = new LPreview();
    preview->previewEnable(nullptr, true, true);
    preview->previewObject(playlist);

    LOutput* sdiOut = new LOutput();
    sdiOut->setDevice(0);
    sdiOut->setSource(playlist);
    sdiOut->setEnabled(true);

    // 4. Add Clips to Rundown
    LItem* item1 = nullptr;
    LItem* item2 = nullptr;
    LItem* cmdItem = nullptr;

    // Add first clip: Play only from 5.0s to 65.0s (1 minute duration)
    playlist->playlistAdd(nullptr, "/media/clips/commercial_break.mp4", "", -1, &item1);
    if (item1) {
        item1->fileInOutSet(5.0, 65.0);
        
        // Probe file metadata
        videoFormatProps probeProps;
        std::string formatStr;
        double playSec = 0.0;
        item1->formatVideoGet(probeProps, formatStr);
        item1->itemPlayTimeGet(playSec);
        std::cout << "Clip 1 Format: " << formatStr << " Duration: " << playSec << "s" << std::endl;
    }

    // Add second clip: Scheduled for 20:30:00 prime-time news
    playlist->playlistAdd(nullptr, "/media/clips/evening_news_intro.mov", "", -1, &item2);
    if (item2) {
        item2->itemTimesSet("20:30:00", "00:00:00", 0);
    }

    // Add automation command: Pause after news intro
    playlist->playlistCommandAdd("pause", "", "", -1, &cmdItem);

    // 5. Start Playout
    playlist->play();

    // 6. Playout Head Monitoring Loop
    int curIdx, nextIdx;
    double filePos, listPos;
    playlist->playlistPosGet(curIdx, nextIdx, filePos, listPos);
    std::cout << "Now Playing Index: " << curIdx << " [Clip Pos: " << filePos << "s | List Pos: " << listPos << "s]" << std::endl;

    return 0;
}

7. VB.NET / C# Playout Integration Example

Demonstrates integrating LPlaylist as a drop-in Medialooks replacement in Windows / Linux .NET playout applications (e.g. Next4Play):

' Visual Basic .NET Playout Controller (Next4Play Drop-In)
Imports Now2Media.SDK

Public Class FormPlayout
    Private m_playlist As LPlaylist
    Private m_preview As LPreview

    Private Sub FormPlayout_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        m_playlist = New LPlaylist()
        m_playlist.SetLicense("YOUR-LICENSE-KEY")

        ' Set broadcast standard
        Dim vp As New VideoFormatProps()
        vp.setVideoFormat = vF_Type.vF_HD1080_50i
        m_playlist.SetVideoFormat(vp)

        ' Attach Preview Control
        m_preview = New LPreview()
        m_preview.PreviewEnable(pnlVideo.Handle, True, True)
        m_preview.PreviewObject(m_playlist)

        ' Load Rundown Grid
        LoadPlaylistGrid()
    End Sub

    Private Sub LoadPlaylistGrid()
        Dim count As Integer = 0
        Dim totalDuration As Double = 0.0
        m_playlist.PlaylistGetCount(count, totalDuration)
        dgvPlaylist.Rows.Clear()

        Dim i As Integer = 0
        While i < count
            Dim pos As Double = 0.0
            Dim path As String = ""
            Dim item As LItem = Nothing

            m_playlist.PlaylistGetByIndex(i, pos, path, item)
            If item IsNot Nothing Then
                Dim inS As Double, outS As Double, durS As Double
                item.FileInOutGet(inS, outS, durS)

                Dim probeV As New VideoFormatProps()
                Dim formatStr As String = ""
                item.FormatVideoGet(probeV, formatStr)

                dgvPlaylist.Rows.Add(i + 1, path, inS, outS, item.PlayTimeGet(), formatStr)
            End If
            i += 1
        End While
    End Sub

    Private Sub TimerPlayout_Tick(sender As Object, e As EventArgs) Handles TimerPlayout.Tick
        Dim curIdx As Integer, nextIdx As Integer
        Dim filePos As Double, listPos As Double
        m_playlist.PlaylistPosGet(curIdx, nextIdx, filePos, listPos)

        lblCurrentIndex.Text = "Index: " & (curIdx + 1).ToString()
        lblClipTime.Text = TimeSpan.FromSeconds(filePos).ToString("hh\:mm\:ss")
        lblTotalTime.Text = TimeSpan.FromSeconds(listPos).ToString("hh\:mm\:ss")
    End Sub

    Private Sub btnPlay_Click(sender As Object, e As EventArgs) Handles btnPlay.Click
        m_playlist.Play()
    End Sub

    Private Sub btnPause_Click(sender As Object, e As EventArgs) Handles btnPause.Click
        m_playlist.Pause()
    End Sub

    Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles btnStop.Click
        m_playlist.Stop()
    End Sub
End Class