I want the video I got from youtube to play on my screen

30 Views Asked by At

I want to make a question solution application. I have a list of questions and when that question is pressed, I want to take it to the youtube video of the relevant question, as an example, I did something like this, I will change it, but there is a problem

this is the code i wrote

import 'package:flutter/material.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
import '../model/datas_model.dart';

class SoruDetaySayfasi extends StatefulWidget {
  final Soru soru;
  late final videoUrl = soru.url;

   SoruDetaySayfasi({super.key, required this.soru});

  @override
  State<SoruDetaySayfasi> createState() => _SoruDetaySayfasiState();
}

class _SoruDetaySayfasiState extends State<SoruDetaySayfasi> {
  final videoUrl = 'https://www.youtube.com/watch? 
v=YMx8Bbev6T4&ab_channel=FlutterUIDev';
  late YoutubePlayerController _controller;

  @override
  void initState() {
    final videoID = YoutubePlayer.convertUrlToId(videoUrl);
    _controller = YoutubePlayerController(initialVideoId: videoID!,
    flags: const YoutubePlayerFlags(
      autoPlay: false,
       
    )
    );
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Soru Detayı'),
      ),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          YoutubePlayer(controller: _controller,
          showVideoProgressIndicator: true,


          )
        ],
      ),
    );
  }
}

aldığım hata ise bu şekilde

if (errorCode is String && (errorMessage == null || errorMessage is String) && !buffer.hasRemaining) { throw PlatformException(code: errorCode, message: errorMessage as String?, details: errorDetails, stacktrace: errorStacktrace);

how can i solve this error

0

There are 0 best solutions below