Coder Social home page Coder Social logo

flutter_tvprovider's Introduction

flutter_tvprovider

This plugin exposes the Android TV basic recommendation API.

With this plugin, you can show PreviewChannels and PreviewPrograms in the Android TV Home screeen.

See https://developer.android.com/codelabs/tv-recommendations-kotlin for more details.

API

The API uses external identifiers (your string, custom ids). Note that TvChannel and TvProgram expose the id field, used intenrally by the Android TV API. This is only for debugging purposes, they are not meant to be used as channelId and programId.

  Future<bool> upsertTvChannel(TvChannel channel, List<TvProgram> programs, bool clearPrograms)
  Future<List<TvChannel>> getTvChannels()
  Future<List<TvProgram>> getTvPrograms(String channelId)
  Future<bool> removeTvProgram(String programId)
  Future<bool> removeTvChannel(String channelId)

Example

  final programs = [
    TvProgram(
        contentId: "le_voyage_dans_la_lun",
        releaseDate: "1902",
        durationMillis: 780,
        title: "Le Voyage Dans la Lun",
        author: "Georges Méliès",
        description: "A group of astronomers go on an expedition to the Moon.",
        intentUri: "https://$packageName/program/le_voyage_dans_la_lun",
        posterArtUri: "https://android-tv-classics.firebaseapp.com/content/le_voyage_dans_la_lun/poster_art_le_voyage_dans_la_lun.jpg"
    ),
    TvProgram(
        contentId: "robinson_crusoe",
        releaseDate: "1903",
        durationMillis: 770,
        title: "Les aventures de Robinson Crusoé",
        author: "Georges Méliès",
        description: "Robinson Crusoe and Friday fight with hostile natives, and eventually retire to their jungle cottage to relax.",
        intentUri: "https://$packageName/program/robinson_crusoe",
        posterArtUri: "https://android-tv-classics.firebaseapp.com/content/robinson_crusoe/poster_art_robinson_crusoe.jpg"
    ),
    TvProgram(
        contentId: "alice_wonderland",
        releaseDate: "1903",
        durationMillis: 600,
        title: "Alice in Wonderland",
        author: "Cecil Hepworth",
        description: "Alice dozes in a garden, awakened by a dithering white rabbit in waistcoat with pocket watch. She follows him down a hole.",
        intentUri: "https://$packageName/program/alice_wonderland",
        posterArtUri: "https://android-tv-classics.firebaseapp.com/content/alice_wonderland/poster_art_alice_wonderland.jpg"
    ),
  ];

  final channel = TvChannel(
      "test_channel",
      "assets/ic_app_channel.png",
      displayName: "Test Channel",
      appLinkIntentUri: "https://$packageName/channel/$channelId"
  );
  try {
    final ok = await FlutterTvprovider.upsertTvChannel(channel, programs, false);
    print(">> upsertTvChannel OK: $ok");
  } catch (e) {
    print(">> upsertTvChannel KO: $e");
  }
  try {
    final channels = await FlutterTvprovider.getTvChannels();
    print(">> getTvChannels OK: $channels");
  } catch (e) {
    print(">> getTvChannels KO: $e");
  }
  var receivedPrograms = <TvProgram>[];
  try {
    receivedPrograms = await FlutterTvprovider.getTvPrograms(channelId);
    print(">> getTvPrograms OK: $receivedPrograms");
  } catch (e) {
    print(">> getTvPrograms KO: $e");
  }
  if (receivedPrograms.length > 0) {
    try {
      // remove second program
      final ok = await FlutterTvprovider.removeTvProgram(receivedPrograms[1].contentId!);
      print(">> removeTvProgram OK: $ok");
    } catch (e) {
      print(">> removeTvProgram KO: $e");
    }
    try {
      final receivedPrograms = await FlutterTvprovider.getTvPrograms(channelId);
      print(">> After Remove OK: ${receivedPrograms}");
    } catch (e) {
      print(">> After Remove KO: $e");
    }
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.