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
704 stars 815 forks source link

[BUG] Many log about errors that don't make sense. MODIFY_AUDIO_SETTINGS - RECORD_AUDIO - CAMERA - BLUETOOTH #416

Open JHBitencourt opened 3 years ago

JHBitencourt commented 3 years ago

Describe the bug Using the new package: youtube_player_iframe: 1.1.0 With a simple video added:

final id = 'pQN-pnXPaVg';

final _controller = YoutubePlayerController(
  initialVideoId: id,
  params: const YoutubePlayerParams(
    showControls: true,
    showFullscreenButton: true,
    autoPlay: false,
    mute: false,
  ),
)
  ..onEnterFullscreen = () {
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.landscapeLeft,
      DeviceOrientation.landscapeRight,
    ]);
  }
  ..onExitFullscreen = () {
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
    ]);
  };

return YoutubePlayerIFrame(
  controller: _controller,
  aspectRatio: 16 / 9,
);

It freezes a little at first, but the video works. The problem is it shows lots of errors in the log:

W/cr_media( 2054): Requires BLUETOOTH permission [log] Unrecognized feature: 'picture-in-picture'. [log] Unrecognized feature: 'picture-in-picture'. E/chromium( 2054): [ERROR:web_contents_delegate.cc(224)] WebContentsDelegate::CheckMediaAccessPermission: Not supported. E/chromium( 2054): [ERROR:web_contents_delegate.cc(224)] WebContentsDelegate::CheckMediaAccessPermission: Not supported. W/cr_media( 2054): Requires MODIFY_AUDIO_SETTINGS and RECORD_AUDIO. No audio device will be available for recording I/CameraManagerGlobal( 2054): Connecting to camera service W/CameraBase( 2054): An error occurred while connecting to camera 1: Status(-8): '1: validateClientPermissionsLocked:958: Caller "package" (PID 10671, UID 2054) cannot open camera "1" without camera permission' E/cr_VideoCapture( 2054): Camera.open: E/cr_VideoCapture( 2054): java.lang.RuntimeException: Fail to connect to camera service E/cr_VideoCapture( 2054): at android.hardware.Camera.(Camera.java:597) E/cr_VideoCapture( 2054): at android.hardware.Camera.open(Camera.java:433) E/cr_VideoCapture( 2054): at org.chromium.media.VideoCaptureFactory.isZoomSupported(chromium-Monochrome.aab-stable-428010120:3) W/CameraBase( 2054): An error occurred while connecting to camera 1: Status(-8): '1: validateClientPermissionsLocked:958: Caller "package" (PID 10671, UID 2054) cannot open camera "1" without camera permission' E/cr_VideoCapture( 2054): Camera.open: E/cr_VideoCapture( 2054): java.lang.RuntimeException: Fail to connect to camera service E/cr_VideoCapture( 2054): at android.hardware.Camera.(Camera.java:597) E/cr_VideoCapture( 2054): at android.hardware.Camera.open(Camera.java:433) E/cr_VideoCapture( 2054): at org.chromium.media.VideoCaptureFactory.getDeviceSupportedFormats(chromium-Monochrome.aab-stable-428010120:3) W/CameraBase( 2054): An error occurred while connecting to camera 0: Status(-8): '1: validateClientPermissionsLocked:958: Caller "package" (PID 10671, UID 2054) cannot open camera "0" without camera permission' E/cr_VideoCapture( 2054): Camera.open: E/cr_VideoCapture( 2054): java.lang.RuntimeException: Fail to connect to camera service E/cr_VideoCapture( 2054): at android.hardware.Camera.(Camera.java:597) E/cr_VideoCapture( 2054): at android.hardware.Camera.open(Camera.java:433) E/cr_VideoCapture( 2054): at org.chromium.media.VideoCaptureFactory.isZoomSupported(chromium-Monochrome.aab-stable-428010120:3) W/CameraBase( 2054): An error occurred while connecting to camera 0: Status(-8): '1: validateClientPermissionsLocked:958: Caller "package" (PID 10671, UID 2054) cannot open camera "0" without camera permission' E/cr_VideoCapture( 2054): Camera.open: E/cr_VideoCapture( 2054): java.lang.RuntimeException: Fail to connect to camera service E/cr_VideoCapture( 2054): at android.hardware.Camera.(Camera.java:597) E/cr_VideoCapture( 2054): at android.hardware.Camera.open(Camera.java:433) E/cr_VideoCapture( 2054): at org.chromium.media.VideoCaptureFactory.getDeviceSupportedFormats(chromium-Monochrome.aab-stable-428010120:3) E/chromium( 2054): [ERROR:web_contents_delegate.cc(224)] WebContentsDelegate::CheckMediaAccessPermission: Not supported. E/chromium( 2054): [ERROR:web_contents_delegate.cc(224)] WebContentsDelegate::CheckMediaAccessPermission: Not supported. W/cr_media( 2054): Requires MODIFY_AUDIO_SETTINGS and RECORD_AUDIO. No audio device will be available for recording

It seems like it is trying to access a bunch of unnecessary features:

W/cr_media( 2054): Requires BLUETOOTH permission W/cr_media( 2054): Requires MODIFY_AUDIO_SETTINGS and RECORD_AUDIO. No audio device will be available for recording Caller "package" (PID 10671, UID 2054) cannot open camera "0" without camera permission'

Technical Details:

stvhrs commented 3 years ago

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

class VideoScreen extends StatefulWidget {

final String id;

VideoScreen({this.id});

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

class _VideoScreenState extends State { YoutubePlayerController _controller; TextEditingController _idController; TextEditingController _seekToController;

PlayerState _playerState; YoutubeMetaData _videoMetaData; double _volume = 100; bool _muted = false; bool _isPlayerReady = false;

@override void initState() { super.initState(); _controller = YoutubePlayerController( initialVideoId: widget.id, flags: const YoutubePlayerFlags( mute: false, autoPlay: true, disableDragSeek: false, loop: false, isLive: false, forceHD: false, enableCaption: true, ), )..addListener(listener); _idController = TextEditingController(); _seekToController = TextEditingController(); _videoMetaData = const YoutubeMetaData(); _playerState = PlayerState.unknown; }

void listener() { if (_isPlayerReady && mounted && !_controller.value.isFullScreen) { setState(() { _playerState = _controller.value.playerState; _videoMetaData = _controller.metadata; }); } }

@override void deactivate() { // Pauses video while navigating to next page. _controller.pause(); super.deactivate(); }

@override void dispose() { _controller.dispose(); _idController.dispose(); _seekToController.dispose(); super.dispose(); }

@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(), body: YoutubePlayer( controller: _controller, showVideoProgressIndicator: true, onReady: () { _controller.addListener(listener); }, ), ); } }

stvhrs commented 3 years ago

there is not a bug, version 7+ works to me

pauline-jubiliz commented 2 years ago

Hello,

I have the same problem.

Too many unnecessary permission requests

BoradAnkur commented 1 month ago

Hello,

I have the same problem.

i have use in Listview using multiple video please give me solutions