Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to launch fullscreen? #62

Closed
MorganeAlinai opened this issue Sep 20, 2020 · 3 comments
Closed

Is it possible to launch fullscreen? #62

MorganeAlinai opened this issue Sep 20, 2020 · 3 comments

Comments

@MorganeAlinai
Copy link

Hi,

For UX reasons, I would prefer the video to launch full screen. I'm displaying videos that would not really be interesting if not full screen.

I'm currently using React Native Youtube for that but it has some issues, like the fact that it is impossible to partially cover the video. I would happily switch to React Native Youtube Iframe if I can launch full screen by default.

Regards

@LonelyCpp
Copy link
Owner

LonelyCpp commented Sep 21, 2020

Hi @MorganeAlinai
Unfortunately it is possible only on ios - #19 (comment)

On android, the player can only be put into true fullscreen mode by user tapping on the fullscreen button.

Although you can try to emulate a fullscreen experience

  • push a screen which has only a view and the player on it
  • set the player width and height to match the screen height and width. (note: player width = screen height)
  • rotate the view by 90 degrees to make the player horizontal

@LonelyCpp
Copy link
Owner

here's a simple snippet to achieve this -

import React, { useEffect, useState } from "react";
import { Dimensions } from "react-native";
import { View } from "react-native";
import YoutubePlayer from "react-native-youtube-iframe";

const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("window");

export default function App() {
  return (
    // rotate by 90 deg for horizontal video
    <View style={{ transform: [{ rotate: "90deg" }] }}>
      <YoutubePlayer
        videoId={"XSqi5s3rfqk"}
        // video height -> screen width
        height={SCREEN_WIDTH}
        // video width -> screen height
        width={SCREEN_HEIGHT}
        // prevent aspect ratio auto sizing
        webViewProps={{
          injectedJavaScript: `
            var element = document.getElementsByClassName('container')[0];
            element.style.position = 'unset';
            element.style.paddingBottom = 'unset';
            true;
          `,
        }}
      />
    </View>
  );
}

@MaheshGawhane11
Copy link

@LonelyCpp Using above code it doesn't match to fullscreen. Its showing in center with small size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants