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] i am not playing youtube video in iphone #422

Open john-boris1984 opened 3 years ago

john-boris1984 commented 3 years ago

Describe the bug I am play youtube using youtube_player_flutter. It works fine on android, but a bug appeared on iphone. The bug appeared in the inappwebview plugin, but I tried all the bug fixes for this, but it does not work.

To Reproduce Steps to reproduce the behavior: import 'dart:async'; import 'package:flutter/material.dart'; import 'package:youtube_player_flutter/youtube_player_flutter.dart';

class VideoPlayerWidget extends StatefulWidget { VideoPlayerWidget({Key key, this.url}) : super(key: key); final String url; @override VideoPlayerWidgetState createState() => VideoPlayerWidgetState(); }

class VideoPlayerWidgetState extends State { YoutubePlayerController vcontrol;

@override void initState() { String id = YoutubePlayer.convertUrlToId(widget.url); vcontrol = YoutubePlayerController( initialVideoId: id, flags: YoutubePlayerFlags( autoPlay: true, mute: false, isLive: true, loop: true), ); vcontrol.addListener(() { debugPrint("${vcontrol.value}"); debugPrint("${vcontrol.flags}"); vcontrol.play(); }); }

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

@override Widget build(BuildContext context) { double width = MediaQuery.of(context).size.width; double height = MediaQuery.of(context).size.height; Size size = new Size(70, 50); return Stack( children: [ Center( child: Container( width: width, height: width / 16 * 9, foregroundDecoration: BoxDecoration(color: Colors.black38), child: YoutubePlayerBuilder( player: YoutubePlayer( controller: vcontrol, showVideoProgressIndicator: true, progressIndicatorColor: Colors.blueAccent, onReady: () { }, ), builder: (context, player) { return ListView( children: [ Container( color: Colors.black87, child: player, ), Padding( padding: EdgeInsets.only( left: width / 2 - size.width / 2, top: width / 3 - size.height / 2), child: Container( width: size.width, height: size.height, decoration: BoxDecoration( color: Color(0xFF3F3F3F).withOpacity(0.9), borderRadius: BorderRadius.circular(18.0)), child: IconButton( icon: Icon( vcontrol.value.isPlaying ? Icons.pause : Icons.play_arrow, color: Colors.white, size: 30.0, ), onPressed: () { setState(() { vcontrol.value.isPlaying ? vcontrol.pause() : vcontrol.play(); }); }))) ], ); }, )), ), ], ); } } Expected behavior bug is showed. [VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: PlatformException(unregistered_view_type, trying to create a view with an unregistered type, unregistered view type: 'com.pichillilorenzo/flutter_inappwebview', null)

Screenshots If applicable, add screenshots to help explain your problem.

Technical Details: this is my podfile. //////////////////////////////////////////////////////

Uncomment this line to define a global platform for your project

platform :ios, '12.0'

CocoaPods analytics sends network stats synchronously affecting flutter build latency.

ENV['COCOAPODS_DISABLE_STATS'] = 'true' ENV['SWIFT_VERSION'] = '5.0'

project 'Runner', { 'Debug' => :debug, 'Profile' => :release, 'Release' => :release, }

def flutter_root generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), FILE) unless File.exist?(generated_xcode_build_settings_path) raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" end

File.foreach(generated_xcode_build_settings_path) do |line| matches = line.match(/FLUTTER_ROOT\=(.*)/) return matches[1].strip if matches end raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do use_frameworks! use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(FILE)) end

post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) end end /////////////////////////////////////////////////////////// my info.plist //////////////////////////////////////////////////////////

LSRequiresIPhoneOS
<true/>
<key>io.flutter.embedded_views_preview</key>   <true/>
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key><true/>
</dict>

///////////////////////////////////////////////////////// Additional context Add any other context about the problem here.

alan2030 commented 2 years ago

same

EDIT: flutter clean helped