targetvideo_flutter 1.0.11 copy "targetvideo_flutter: ^1.0.11" to clipboard
targetvideo_flutter: ^1.0.11 copied to clipboard

A new Flutter plugin for video reproduction using native BridSDK for iOS and Android.

TargetVideo Flutter Plugin #

A Flutter plugin for video playback with ad support using native BridSDK for iOS and Android.

What is this repository for? #

This SDK aims at easily playing videos with or without ads in your Flutter application. Apps built with this SDK integrate with video hosting, streaming, and analytics services.

How do I get set up? #

  • Add targetvideo_flutter: ^x.x.x to your pubspec.yaml and run flutter pub get.
  • Import the player in your class:
import 'package:targetvideo_flutter/targetvideo_player.dart';
import 'package:targetvideo_flutter/targetvideo_player_platform_view.dart';
  • Add this line in your iOS Podfile, just under platform :ios, 'x.x':
install! 'cocoapods', :disable_input_output_paths => true
  • Add NSUserTrackingUsageDescription to your app Info.plist.

Basic Usage #

// 1. Add the view widget
TargetVideoPlayerView(
  onCreated: (viewId) {
    // 2. Create player
    final TargetVideoPlayer player = TargetVideoPlayer(playerReference: "myPlayer");
    // 3. Load video
    player.load(playerId: 123, mediaId: 456, typeOfPlayer: "Single", viewId: viewId);
    // 4. Listen to events
    player.handleAllPlayerEvents((event) {
      print(event);
    });
  },
)

Player Constructor Parameters #

Parameter Type Description
playerReference String Unique identifier for the player instance (required)
controlAutoplay bool? Enable client-controlled autoplay
scrollOnAd bool? Allow scrolling during ads (iOS only)
creditsLabelColor String? Credits label color as 6 hex characters, without #
setCornerRadius int? Corner radius of the player in pixels
localization String? Language code for player UI and IMA (e.g. "en", "de")
doubleTapSeek int? Seconds to seek on double tap
seekPreview int? 1 = enabled, 2 = fullscreen only, 0 = disabled
bplrMacros Map<String, String>? Custom targeting parameters for ad tag macros (see below)

bplr Macros (Custom Ad Targeting) #

Use bplrMacros to pass contextual targeting parameters that replace [bplr_*] placeholders in VAST ad tag URLs. Must be set before calling load().

final TargetVideoPlayer player = TargetVideoPlayer(
  playerReference: "myPlayer",
  bplrMacros: {
    "bplr_keywords": "sports,news",
    "bplr_section": "homepage",
    "bplr_page_type": "article",
    "bplr_content_id": "example123",
  },
);
player.load(playerId: 123, mediaId: 456, typeOfPlayer: "Single", viewId: viewId);

Any key/value pair can be passed. If the ad tag URL contains a matching placeholder (e.g. [bplr_keywords]), it will be replaced with the provided value. Parameters are also appended to cust_params in Google Ad Manager VAST URLs.

You can also set macros via setter after construction, before calling load():

player.bplrMacros = {"bplr_keywords": "tech"};
player.load(playerId: 123, mediaId: 456, typeOfPlayer: "Single", viewId: viewId);

Player Methods #

Method Returns Description
load(playerId, mediaId, typeOfPlayer, viewId) Future<void> Loads a video or playlist. typeOfPlayer: "Single" or "Playlist"
play() Future<void> Plays the video
pause() Future<void> Pauses the video
previous() Future<void> Plays the previous video in the playlist
next() Future<void> Plays the next video in the playlist
mute() Future<void> Mutes the player
unMute() Future<void> Unmutes the player
setFullscreen(bool) Future<void> Enters or exits fullscreen
showControls() Future<void> Shows player controls
hideControls() Future<void> Hides player controls
isAdPlaying() Future<bool?> Returns true if an ad is playing
getPlayerCurrentTime() Future<num?> Current playback position in milliseconds
getAdDuration() Future<num?> Duration of the current ad in milliseconds
getVideoDuration() Future<num?> Duration of the current video in milliseconds
isPaused() Future<bool?> Returns true if the player is paused
isRepeated() Future<bool?> Returns true if the video is in repeat mode
isAutoplay() Future<bool?> Returns true if autoplay is enabled
destroyPlayer() Future<void> Destroys the player and releases resources
handleAllPlayerEvents(callback) void Listens to all player and ad events

Player Events #

Events are received as a Map with the following keys:

Key Value
playerReference The player's reference string
type "PlayerEvent" or "AdEvent"
event Event name (for player events)
ad Ad event name (for ad events)
player.handleAllPlayerEvents((event) {
  if (event['type'] == 'PlayerEvent') {
    print('Player event: ${event['event']}');
  } else {
    print('Ad event: ${event['ad']}');
  }
});
0
likes
150
points
876
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A new Flutter plugin for video reproduction using native BridSDK for iOS and Android.

Homepage
Repository

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on targetvideo_flutter

Packages that implement targetvideo_flutter