hls_player 2.8.4 copy "hls_player: ^2.8.4" to clipboard
hls_player: ^2.8.4 copied to clipboard

this packages is a custom video player build to cast streaming to TV devices

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:hls_player/hls_player.dart';
import 'package:hls_player/model/video.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    // initPlatformState();
    // initZappingPlatformState();
  }

  static Future<void> playVideo() async {
    const uRL_VIDEO =
        r"https://virginia1.trapemn.tv:1936/live/test2/playlist.m3u8";
    try {
      await HlsPlayer.initializeVideo(url: uRL_VIDEO).then((onValue) {
        print(onValue);
        Timer.periodic(Duration(seconds: 5), (Timer t) => initGetVideoLink());
      }).catchError((onError) {
        print(onError);
      });
    } on PlatformException {}
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  static Future<void> initPlatformState({@required int isVivo}) async {
    const uRL_VIDEO =
        r"https://virginia1.trapemn.tv:1936/live/test2/playlist.m3u8";
    final Video video = Video();

    video.titulo = "titulo";
    video.descripcion = "descripcion";
    video.imagenPath =
        "https://bantel.iptvperu.tv/img/sections/icono_1687566796.jpg?w=1921&h=1081";
    video.numeroCanal = 1;
    video.vivo = isVivo;
    video.studio = 1381;
    video.linkReproductor = uRL_VIDEO;

    try {
      await HlsPlayer.initializeZapping(
              canales: [video],
              playVideoAtIndex: 0,
              isSearchingItem: true,
              urlEPG:
                  r"http://170.79.102.232:18080/30h_c51b182583a9d4a8_$5da43c0fb7fbd7b0c7d3/STUDIO.json")
          .then((onValue) {
        print(onValue);
        Timer.periodic(Duration(seconds: 5), (Timer t) => initGetVideoLink());
      }).catchError((onError) {
        print(onError);
      });
    } on PlatformException {}
  }

  static Future<void> initZappingPlatformState() async {
    const uRL_VIDEO =
        "https://virginia1.trapemn.tv:1936/live/test2/playlist.m3u8";
    const uRL_VIDEO2 = "http://virginia1.trapemn.tv:50080/PinguinoTV/index.mpd";
    const uRL_VIDEO3 = "srt://170.79.100.123:40041";

    final Video video = Video();

    video.titulo = "titulo";
    video.descripcion = "descripcion";
    video.imagenPath =
        "https://bantel.iptvperu.tv/img/sections/icono_1687566796.jpg?w=1921&h=1081";
    video.numeroCanal = 1;
    video.vivo = 0;
    video.studio = 1381;
    video.linkReproductor = uRL_VIDEO;

    final Video video2 = Video();

    video2.titulo = "titulo";
    video2.descripcion = "descripcion";
    video2.imagenPath =
        "https://170.79.102.232:8443/img/channels/logo_1567784648.png?w=500&h=500";
    video2.numeroCanal = 2;
    video2.vivo = 1;
    video2.studio = 1382;
    video2.linkReproductor = uRL_VIDEO2;

    final Video video3 = Video();

    video3.titulo = "titulo";
    video3.descripcion = "descripcion";
    video3.imagenPath =
        "https://170.79.102.232:8443/img/channels/logo_1565631656.png?w=500&h=500";
    video3.numeroCanal = 3;
    video3.vivo = 1;
    video3.studio = 1383;
    video3.linkReproductor = uRL_VIDEO3;

    final canales = [video, video2, video3];

    try {
      await HlsPlayer.initializeZapping(
              canales: canales,
              playVideoAtIndex: 2,
              isSearchingItem: false,
              urlEPG:
                  r"http://170.79.102.232:18080/30h_c51b182583a9d4a8_$5da43c0fb7fbd7b0c7d3/STUDIO.json")
          .then((onValue) {
        print(onValue);
        Timer.periodic(Duration(seconds: 5), (Timer t) => initGetVideoLink());
      }).catchError((onError) {
        print(onError);
      });
    } on PlatformException {}
  }

  static Future<void> initGetVideoLink() async {
    try {
      await HlsPlayer.getVideoLink().then((onValue) {
        print(onValue);
      }).catchError((onError) {
        print(onError);
      });
    } on PlatformException {}
  }

  Widget testWidget = new MediaQuery(
    data: new MediaQueryData(),
    child: new MaterialApp(
      home: Scaffold(
          body: Center(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Padding(
              padding: EdgeInsets.only(top: 100, bottom: 50),
              child: GestureDetector(
                child: Text(
                  'Buscar video',
                  style: TextStyle(fontSize: 18.0),
                ),
                onTap: () {
                  playVideo();
                },
              ),
            ),
            GestureDetector(
              child: Text(
                'Buscar Streaming',
                style: TextStyle(fontSize: 18.0),
              ),
              onTap: () {
                initPlatformState(isVivo: 1);
              },
            ),
            Padding(
              padding: EdgeInsets.only(top: 100, bottom: 50),
              child: GestureDetector(
                child: Text(
                  'play zapping',
                  style: TextStyle(fontSize: 18.0),
                ),
                onTap: () {
                  initZappingPlatformState();
                },
              ),
            ),
          ],
        ),
      )),
    ),
  );

  @override
  Widget build(BuildContext context) {
    return testWidget;
  }
}
8
likes
30
pub points
67%
popularity

Publisher

unverified uploader

this packages is a custom video player build to cast streaming to TV devices

Homepage

License

unknown (LICENSE)

Dependencies

flutter, meta

More

Packages that depend on hls_player