Reputation:
I wanted to use YouTube Player in my app for both Android and Desktop. I created it using Flutter and now it is working properly. If I build it in windows, then it is running, but the player is not showing any videos.
I know flutter currently is not stable for windows. But other simple functionalities are working properly. However, I could not use YouTube Player for this. Does anyone have the solution or ideas for this problem?
Here is my source code:
import 'package:flutter/material.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin {
//AnimationController _controller;
String video_url = "https://www.youtube.com/watch?v=QfkFPedJ6UQ";
YoutubePlayerController _controller;
@override
void initState() {
//_controller = AnimationController(vsync: this);
_controller = YoutubePlayerController(
initialVideoId: YoutubePlayer.convertUrlToId(video_url),
);
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Programmer UZ")
),
body: Container(
child: SingleChildScrollView(
child: Column(
children: <Widget>[
YoutubePlayer(
controller: _controller,
),
],
),
)
),
);
}
}
Upvotes: 3
Views: 2085
Reputation: 21579
But other simple functionalities are working properly.
The YouTube player package isn't simple functionality; it's using an inline webview plugin. As a plugin, it's based on per-platform code, so would need a Windows implementation, which it doesn't have. And implementing an inline webview plugin on Windows requires platform view support in the Windows Flutter embedding, which doesn't exist yet.
There is currently no way to do inline web content in Flutter for desktop.
Upvotes: 4