-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaudio_only.dart
67 lines (61 loc) · 1.98 KB
/
audio_only.dart
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
60
61
62
63
64
65
66
67
import 'package:bitmovin_player/bitmovin_player.dart';
import 'package:bitmovin_player_example/controls.dart';
import 'package:bitmovin_player_example/env/env.dart';
import 'package:bitmovin_player_example/platform.dart';
import 'package:flutter/material.dart';
class AudioOnly extends StatefulWidget {
const AudioOnly({super.key});
static String routeName = 'AudioOnly';
@override
State<AudioOnly> createState() => _AudioOnlyState();
}
class _AudioOnlyState extends State<AudioOnly> {
final _sourceConfig = SourceConfig(
url: isIOS
? 'https://cdn.bitmovin.com/content/assets/MI201109210084/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8'
: 'https://cdn.bitmovin.com/content/assets/MI201109210084/mpds/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.mpd',
type: isIOS ? SourceType.hls : SourceType.dash,
);
final _player = Player(
config: const PlayerConfig(
key: Env.bitmovinPlayerLicenseKey,
remoteControlConfig: RemoteControlConfig(isCastEnabled: false),
),
);
@override
void initState() {
_player.loadSourceConfig(_sourceConfig);
super.initState();
}
@override
void dispose() {
_player.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Audio Only'),
),
body: Column(
children: [
Container(
margin: const EdgeInsets.only(top: 5),
child: Controls(
onLoadPressed: () => _player.loadSourceConfig(_sourceConfig),
onPlayPressed: _player.play,
onPausePressed: _player.pause,
onMutePressed: _player.mute,
onUnmutePressed: _player.unmute,
onSkipForwardPressed: () async =>
_player.seek(await _player.currentTime + 10),
onSkipBackwardPressed: () async =>
_player.seek(await _player.currentTime - 10),
),
),
],
),
);
}
}