sarbagyastha / youtube_player_flutter

A Flutter plugin for inline playback or streaming of YouTube videos using the official iFrame Player API.
https://youtube.sarbagyastha.com.np
BSD 3-Clause "New" or "Revised" License
692 stars 784 forks source link

[BUG] full-screen option not working on ios #447

Open chitrank2050 opened 3 years ago

chitrank2050 commented 3 years ago

Describe the bug Hi, The option to toggle full-screen is not working on ios device. As soon as I click on the toggle option nothing happens.

Technical Details:

CODE

This isthe code for the player wrapper:

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';

class PlayYT extends StatefulWidget {
  final String ytLink;

  const PlayYT(this.ytLink, {Key key}) : super(key: key);

  static Route route(String ytLink) {
    return CupertinoPageRoute<void>(
      builder: (BuildContext _) => PlayYT(ytLink),
    );
  }

  @override
  _PlayYTState createState() => _PlayYTState();
}

class _PlayYTState extends State<PlayYT> {
  YoutubePlayerController _youtubeController;
  @override
  void initState() {
    super.initState();
    _youtubeController = YoutubePlayerController(
      initialVideoId: widget.ytLink,
      flags: YoutubePlayerFlags(
        autoPlay: true,
        forceHD: true,
        hideControls: false,
        hideThumbnail: false,
      ),
    );
  }

  @override
  void dispose() {
    _youtubeController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    print('YOOOO');
    return _buildContentAndroid;
  }

  get _buildContentAndroid => WillPopScope(
        onWillPop: () {
          _youtubeController.pause();
          // SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
          Navigator.of(context).pop();
          return Future<bool>.value(true);
        },
        child: YoutubePlayerBuilder(
          onEnterFullScreen: () {
            print('>>>>>onEnterFullScreen called!!');
          },
          onExitFullScreen: () {
            print('>>>>>onFullScreen called!!');
          },
          player: YoutubePlayer(
            controller: _youtubeController,
            showVideoProgressIndicator: true,
            topActions: <Widget>[
              const SizedBox(width: 16.0),
              IconButton(
                icon: const Icon(
                  Icons.close,
                  color: Colors.white,
                  size: 25.0,
                ),
                onPressed: () {
                  _youtubeController.pause();
                  Navigator.of(context).pop();
                },
              ),
              const SizedBox(width: 16.0),
              Expanded(
                child: Text(
                  _youtubeController.metadata.title,
                  style: const TextStyle(
                    color: Colors.white,
                    fontSize: 18.0,
                  ),
                  overflow: TextOverflow.ellipsis,
                  maxLines: 1,
                ),
              ),
            ],
            onEnded: (data) {
              Navigator.of(context).pop();
            },
          ),
          builder: (context, player) => Scaffold(
            backgroundColor: Colors.black,
   body: Center(
              child: FittedBox(
                fit: BoxFit.fitWidth,
                child: player,
              ),
            ),
          ),
        ),
      );
}
kidandcat commented 3 years ago

Any news?

misaelriojasftf commented 2 years ago

any news? x2

lampian commented 1 year ago

Same issue running flutter 3.3.4 and 8.1.0 on iOS. It a show stopper..

pbayog00 commented 1 year ago

In my case, the full screen mode was not working because I didn't have the available device orientations correctly configured in Info.plist

You have to edit the UISupportedInterfaceOrientations variable in app -> Runner -> Info.plist

Answer based on https://github.com/flutter/flutter/issues/119473#issuecomment-1415631020