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

Bad quality #51

Closed
Krosnoz opened this issue Aug 4, 2020 · 5 comments
Closed

Bad quality #51

Krosnoz opened this issue Aug 4, 2020 · 5 comments

Comments

@Krosnoz
Copy link

Krosnoz commented Aug 4, 2020

Hello, I'm trying to make a movie app, and I want to display some trailers.

The problem is the quality, it's always set to "small", and I can't change it, I don't have the controls for it.

Here is my code :

import { StyleSheet, View, Dimensions } from 'react-native'
import React from 'react'
import YoutubePlayer from 'react-native-youtube-iframe'

export default class Trailer extends React.Component {

    constructor(props) {
        super(props)
        this.state = {
            playing: true,
            videoID: this.props.route.params.videoID,
            width: Dimensions.get('window').width,
        }
    }

    onLayout = (event) => {
        this.setState({ width: event.nativeEvent.layout.width })
    }

    render() {
        return (
            <View style={styles.mainContainer} onLayout={this.onLayout.bind(this)}>
                <YoutubePlayer
                    height={this.state.width * (9 / 16)}
                    width={this.state.width}
                    videoId={this.state.videoID}
                    play={this.state.playing}
                    onPlaybackQualityChange={q => console.log(q)}
                    initialPlayerParams={{
                        rel: 0
                    }}
                />
            </View>
        )
    }

}

const styles = StyleSheet.create({
    mainContainer: {
        flex: 1,
        justifyContent: "center",
        alignItems: "center",
        backgroundColor: "#000000"
    },
});

Does someone have an idea to have a better quality ? Already try a webview, but they turnoff the forced quality.

Thanks !

@LonelyCpp
Copy link
Owner

Unfortunately, programatically setting video quality is not allowed by youtube.

API Doc | Youtube Doc

the API no longer supports functions for setting or retrieving playback quality. To give you the best viewing experience, YouTube adjusts the quality of your video stream based on your viewing conditions.

The user can still manually change quality by clicking on the three dots on the top right corner, for which there is a callback if you want - doc

@LonelyCpp
Copy link
Owner

Its safe to assume that users who have reasonably good internet will get a better video quality by default, and bad internet is paired with poor quality.

@Krosnoz
Copy link
Author

Krosnoz commented Aug 5, 2020

Hello, thank you for your answer, in spite of that, I think that the problem is not related to the connection, I currently have the fiber, I am in wifi but the speed goes very well.

chrome_LdJ7o5XDsJ

Another thing, I don't have the parameters to change the quality, here is what happens when I click on the three little dots, and the general controls.

Screenshot_20200805-103418
Screenshot_20200805-103422

I'm currently debugging on a OnePlus 6 Android OxygenOS 10.3.4, the size I get back from Dimensions.get('window') is 400x800, I also read that YouTube automatically changes the quality related to the size of the device. So I tried to just multiply x 4 the received value (it's ugly I know), but it doesn't change my problem.

So I wanted to try something else, I debugged on an android emulator, and I get the "large" callback so full HD, I don't understand why on my phone, it doesn't work. This one returns 400x800 also in size, the code is the same and still no possibility to change the quality.

Thanks for your time.

@LonelyCpp
Copy link
Owner

You are right, there isn't a quality selector in the menu. My bad..

I get the "large" callback so full HD

That sounds right, only callbacks to the quality change are accessible as of now ☹️ The link to the 2019 revision history (in my previous comment) is all the info we have on quality

@Krosnoz
Copy link
Author

Krosnoz commented Aug 6, 2020

Hello, thanks for the answer, I guess it's my version of android that's the problem, I'll deal with it, thanks!

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

2 participants