Anonymous
Видео на YouTube в Project Project
Сообщение
Anonymous » 20 сен 2025, 15:57
У меня есть приложение Flutter с использованием youtube_player_iframe: ^5.2.1. On my iPhone 16 Pro Max, videos play fine, but on some devices like Android tablets or smaller screens than iPhone 16 Pro max every video fails inside the in-app player with “This video is unavailable (Error 15)”.
here is my code below
Код: Выделить всё
// lib/pages/player_page.dart
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:youtube_player_iframe/youtube_player_iframe.dart';
class PlayerPage extends StatefulWidget {
final String videoId;
final String title;
const PlayerPage({super.key, required this.videoId, required this.title});
@override
State createState() => _PlayerPageState();
}
class _PlayerPageState extends State {
late final YoutubePlayerController _yt;
@override
void initState() {
super.initState();
_yt = YoutubePlayerController.fromVideoId(
videoId: widget.videoId,
autoPlay: true,
params: const YoutubePlayerParams(
showControls: true,
showFullscreenButton: true,
strictRelatedVideos: true,
enableCaption: false,
playsInline: true,
enableJavaScript: true,
),
);
}
@override
void dispose() {
_yt.close();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title:
Text(widget.title, style: GoogleFonts.baloo2(fontWeight: FontWeight.w700)),
),
body: Center(
child: AspectRatio(
aspectRatio: 16 / 9,
child: YoutubePlayer(controller: _yt),
),
),
);
}
}
Подробнее здесь:
https://stackoverflow.com/questions/797 ... ject-embed
1758373071
Anonymous
У меня есть приложение Flutter с использованием youtube_player_iframe: ^5.2.1. On my iPhone 16 Pro Max, videos play fine, but on some devices like Android tablets or smaller screens than iPhone 16 Pro max every video fails inside the in-app player with “This video is unavailable (Error 15)”. here is my code below [code]// lib/pages/player_page.dart import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:youtube_player_iframe/youtube_player_iframe.dart'; class PlayerPage extends StatefulWidget { final String videoId; final String title; const PlayerPage({super.key, required this.videoId, required this.title}); @override State createState() => _PlayerPageState(); } class _PlayerPageState extends State { late final YoutubePlayerController _yt; @override void initState() { super.initState(); _yt = YoutubePlayerController.fromVideoId( videoId: widget.videoId, autoPlay: true, params: const YoutubePlayerParams( showControls: true, showFullscreenButton: true, strictRelatedVideos: true, enableCaption: false, playsInline: true, enableJavaScript: true, ), ); } @override void dispose() { _yt.close(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title, style: GoogleFonts.baloo2(fontWeight: FontWeight.w700)), ), body: Center( child: AspectRatio( aspectRatio: 16 / 9, child: YoutubePlayer(controller: _yt), ), ), ); } }[/code] Подробнее здесь: [url]https://stackoverflow.com/questions/79770237/youtube-videos-in-flutter-project-embed[/url]