hls_player 2.4.3 hls_player: ^2.4.3 copied to clipboard
A new flutter plugin project.
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();
}
// Platform messages are asynchronous, so we initialize in an async method.
static Future<void> initPlatformState({@required int isVivo}) async {
const uRL_VIDEO = r"http://45.236.127.7:9752/live/John/W1f15p33d$$/283.m3u8";
final Video video = Video();
video.titulo = "titulo";
video.descripcion = "descripcion";
video.imagenPath =
"https://170.79.102.232:8443/img/channels/logo_1587071125.png?w=500&h=500";
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 =
"http://170.79.102.223:20080/files/Ingreso%20e%20inicio%20-%2001.mp4";
const uRL_VIDEO2 = "http://mdstrm.com/video/5a29c07e5522e40a45beb669.m3u8";
const uRL_VIDEO3 =
"http://unlimited1-cl.dps.live/campustv/campustv.smil/playlist.m3u8";
final Video video = Video();
video.titulo = "titulo";
video.descripcion = "descripcion";
video.imagenPath =
"https://170.79.102.232:8443/img/channels/logo_1587071125.png?w=500&h=500";
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: Column(
children: <Widget>[
RaisedButton(
child: Text(
'Buscar video',
style: TextStyle(fontSize: 18.0),
),
onPressed: () {
initPlatformState(isVivo: 0);
},
),
RaisedButton(
child: Text(
'Buscar Streaming',
style: TextStyle(fontSize: 18.0),
),
onPressed: () {
initPlatformState(isVivo: 1);
},
),
RaisedButton(
child: Text(
'play zapping',
style: TextStyle(fontSize: 18.0),
),
onPressed: () {
initZappingPlatformState();
},
),
],
)),
),
);
@override
Widget build(BuildContext context) {
return testWidget;
}
}