Switch media to another player

This commit is contained in:
estevez-dev
2019-09-15 17:29:49 +03:00
parent 8fc7d0b61e
commit 340e8569cc
7 changed files with 109 additions and 50 deletions

View File

@ -3,8 +3,9 @@ part of '../main.dart';
class PlayMediaPage extends StatefulWidget {
final String mediaUrl;
final String mediaType;
PlayMediaPage({Key key, this.mediaUrl}) : super(key: key);
PlayMediaPage({Key key, this.mediaUrl, this.mediaType}) : super(key: key);
@override
_PlayMediaPageState createState() => new _PlayMediaPageState();
@ -22,13 +23,22 @@ class _PlayMediaPageState extends State<PlayMediaPage> {
bool _isMediaExtractorExist = false;
StreamSubscription _stateSubscription;
StreamSubscription _refreshDataSubscription;
final List<String> _contentTypes = ["movie", "video", "music", "image", "image/jpg", "playlist"];
List<String> _contentTypes = ["movie", "video", "music", "image", "image/jpg", "playlist"];
@override
void initState() {
super.initState();
_mediaUrl = widget.mediaUrl;
_contentType = _contentTypes[0];
if (widget.mediaType.isNotEmpty) {
if (!_contentTypes.contains(widget.mediaType)) {
_contentTypes.insert(0, widget.mediaType);
_contentType = _contentTypes[0];
} else {
_contentType = widget.mediaType;
}
} else {
_contentType = _contentTypes[0];
}
_stateSubscription = eventBus.on<StateChangedEvent>().listen((event) {
if (event.entityId.contains("media_player")) {
Logger.d("State change event handled by play media page: ${event.entityId}");