Skip to content

Player controls are not visible anymore, can't seek, see time, etc. #1213

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

Open
anonym24 opened this issue Apr 23, 2025 · 11 comments
Open

Player controls are not visible anymore, can't seek, see time, etc. #1213

anonym24 opened this issue Apr 23, 2025 · 11 comments
Labels

Comments

@anonym24
Copy link

anonym24 commented Apr 23, 2025

com.pierfrancescosoffritti.androidyoutubeplayer:core:12.1.1 (latest version)

So recently player controls stopped appearing. I believe YouTube has changed something.

        val iFramePlayerOptions = IFramePlayerOptions.Builder()
            .controls(1)
            .fullscreen(0) // disable full screen button
            .langPref(Locale.getDefault().language)
            .build()
        <com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
            android:id="@+id/player_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center" />

I didn't make any updates to this app, so it worked normally not a long time ago

I can notice they are visible at first player opening but then they disappear fast

@anonym24 anonym24 added the bug label Apr 23, 2025
@anonym24 anonym24 changed the title Controls are not visible anymore, can seek, see time, etc. Controls are not visible anymore, can't seek, see time, etc. Apr 23, 2025
@anonym24 anonym24 changed the title Controls are not visible anymore, can't seek, see time, etc. Player controls are not visible anymore, can't seek, see time, etc. Apr 23, 2025
@PierfrancescoSoffritti
Copy link
Owner

Controls still show up in the sample app. Is that not the case for you?

@anonym24
Copy link
Author

anonym24 commented Apr 24, 2025

ok, I tried sample and it seems to be working fine, then I copied my player class activity to your project and it also works fine, controls are there, I'm trying figure out what's wrong, why the same code doesn't work in my own project, basically controls are visible but for a very short time and they never become visible again...

UPDATE: actually, I reproduced the issue in your sample with my code, I will send the modified sample as example soon

@anonym24
Copy link
Author

anonym24 commented Apr 24, 2025

Here's the example video of the issue and tiny sample app to reproduce it. Rarely controls can stay visible when starting the app, but in most cases, they aren't, and when tapping to pause the video, they won't appear.

ScreenVideoRecording.mp4

FullScreenSampleYouTubeApp.zip

So, I use youTubePlayer.toggleFullscreen() to enter fullscreen mode and then controls are gone forever.

Main code from this sample:

Activity:

package com.pierfrancescosoffritti.androidyoutubeplayer.core.sampleapp.examples.simpleExample

import android.content.res.Configuration
import android.media.AudioManager
import android.os.Bundle
import android.view.View
import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.PlayerConstants
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.AbstractYouTubePlayerListener
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.FullscreenListener
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.options.IFramePlayerOptions
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
import com.pierfrancescosoffritti.aytplayersample.R
import java.util.Locale

class FullScreenSampleActivity : AppCompatActivity() {
    private lateinit var youTubePlayerView: YouTubePlayerView
    private lateinit var fullscreenViewContainer: FrameLayout

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        volumeControlStream = AudioManager.STREAM_MUSIC

        setContentView(R.layout.activity_simple_example)

        youTubePlayerView = findViewById<YouTubePlayerView>(R.id.youtube_player_view)
        fullscreenViewContainer = findViewById<FrameLayout>(R.id.full_screen_view_container)

        initPlayer()
    }

    private fun initPlayer() {
        val iFramePlayerOptions = IFramePlayerOptions.Builder()
            .controls(1)
            .fullscreen(0) // disable full screen button
            .langPref(Locale.getDefault().language)
            .build()

        youTubePlayerView.addFullscreenListener(object : FullscreenListener {
            override fun onEnterFullscreen(fullscreenView: View, exitFullscreen: () -> Unit) {
                // the video will continue playing in fullscreenView
                fullscreenViewContainer.addView(fullscreenView)
                youTubePlayerView.isVisible = false
            }

            override fun onExitFullscreen() {
                // just exist this activity, we only support playback in fullscreen
                onBackPressedDispatcher.onBackPressed()
            }
        })

        youTubePlayerView.initialize(
            object : AbstractYouTubePlayerListener() {
                override fun onReady(youTubePlayer: YouTubePlayer) {
                    youTubePlayer.loadVideo("S0Q4gqBUs7c", 0f)
                    youTubePlayer.toggleFullscreen()
                }

                override fun onStateChange(
                    youTubePlayer: YouTubePlayer,
                    state: PlayerConstants.PlayerState
                ) {
                    super.onStateChange(youTubePlayer, state)
                }
            },
            iFramePlayerOptions
        )

        lifecycle.addObserver(youTubePlayerView)
    }
}

Layout:


<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
        android:id="@+id/youtube_player_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:enableAutomaticInitialization="false" />

    <FrameLayout
        android:id="@+id/full_screen_view_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</FrameLayout>

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="false"
        android:hardwareAccelerated="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity
            android:name="com.pierfrancescosoffritti.androidyoutubeplayer.core.sampleapp.examples.simpleExample.FullScreenSampleActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout"
            android:exported="true"
            android:hardwareAccelerated="true"
            android:label="@string/simple_example"
            android:launchMode="singleInstance"
            android:screenOrientation="sensor">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>

App build.gradle:

plugins {
    id "com.android.application"
    id "kotlin-android"
}

android {
    compileSdk 36

    defaultConfig {
        minSdk 21
        targetSdk 36
        versionCode 1
        versionName "1.0"
    }

    namespace 'com.pierfrancescosoffritti.aytplayersample'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17
    }
}

dependencies {
    implementation "androidx.appcompat:appcompat:1.7.0"
    implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:12.1.1'
}

@MKohni
Copy link

MKohni commented Apr 24, 2025

I got the same problem. Some devices show all the controls, while others only display the video.

@MKohni
Copy link

MKohni commented Apr 25, 2025

I found out that with every other reinstallation of the APK, the UI and buttons reappear. Maybe it has something to do with YouTube's UI changes?

@anonym24
Copy link
Author

anonym24 commented Apr 25, 2025

The issue occurs when switching to fullscreen programmatically. However, if we disable that and instead display a fullscreen button for users to click, it works fine — but we want to control fullscreen programmatically.

@anonym24
Copy link
Author

I found out that with every other reinstallation of the APK, the UI and buttons reappear. Maybe it has something to do with YouTube's UI changes?

I tried to clear data/cache of the app and controls returned

@PierfrancescoSoffritti
Copy link
Owner

The sample app has an example for full screen, does it happen there?

@anonym24
Copy link
Author

anonym24 commented Apr 27, 2025

yes.
I mean, two people already confirmed it,
but yeah, same issue with your official full screen example

paused, no controls:

Image

@PierfrancescoSoffritti
Copy link
Owner

I can't reproduce in the sample app. What are the steps there? I toggle full screen programmatically by clicking the "toggle full screen" button outside the player, and it works well.

@anonym24
Copy link
Author

anonym24 commented Apr 28, 2025

just try to install it a couple of times from android studio without deleting previous version

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

No branches or pull requests

3 participants