forked from jhomlala/betterplayer
-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathhls_audio_page.dart
More file actions
59 lines (55 loc) · 1.78 KB
/
hls_audio_page.dart
File metadata and controls
59 lines (55 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import 'package:better_player/better_player.dart';
import 'package:better_player_example/constants.dart';
import 'package:flutter/material.dart';
class HlsAudioPage extends StatefulWidget {
@override
_HlsAudioPageState createState() => _HlsAudioPageState();
}
class _HlsAudioPageState extends State<HlsAudioPage> {
late BetterPlayerController _betterPlayerController;
@override
void initState() {
print("_HlsAudioPageState");
BetterPlayerConfiguration betterPlayerConfiguration =
BetterPlayerConfiguration(
aspectRatio: 16 / 9,
fit: BoxFit.contain,
autoPlay: true,
);
BetterPlayerDataSource dataSource = BetterPlayerDataSource(
BetterPlayerDataSourceType.network,
Constants.elephantDreamStreamUrl,
);
_betterPlayerController = BetterPlayerController(betterPlayerConfiguration);
_betterPlayerController.setupDataSource(dataSource);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("HLS Audio"),
),
body: Column(
children: [
const SizedBox(height: 8),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
"Click on overflow menu (3 dots) and select Audio. You can choose "
"audio track from HLS stream. Better Player will setup audio"
" automatically for you.",
style: TextStyle(fontSize: 16),
),
),
_betterPlayerController.isVideoInitialized() ?? false
? AspectRatio(
aspectRatio: 16 / 9,
child: BetterPlayer(controller: _betterPlayerController),
)
: Container(),
],
),
);
}
}