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

StyledPlayerView Custom Controller Support #7962

Closed
ahmetberkinc opened this issue Sep 22, 2020 · 4 comments
Closed

StyledPlayerView Custom Controller Support #7962

ahmetberkinc opened this issue Sep 22, 2020 · 4 comments
Assignees
Labels

Comments

@ahmetberkinc
Copy link

ahmetberkinc commented Sep 22, 2020

[REQUIRED] Searched documentation and issues

https://github.com/google/ExoPlayer/blob/release-v2/RELEASENOTES.md

[REQUIRED] Question

When I was in Exoplayer 2.11.4 version, I was able to replace the SimpleExoPlayerView controller with app: controller_layout_id via xml. I wanted to switch to SytledPlayerView structure with Exoplayer 2.12.0 version. But when I give my old controller over the layout, the application fails. Is there any way to customize the StyledPlayerView controller?

A full bug report captured from the device

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.edittexttest, PID: 9595
    java.lang.NullPointerException: throw with null exception
        at com.google.android.exoplayer2.util.Assertions.checkNotNull(Assertions.java:147)
        at com.google.android.exoplayer2.ui.StyledPlayerControlView$TextTrackSelectionAdapter.init(StyledPlayerControlView.java:2005)
        at com.google.android.exoplayer2.ui.StyledPlayerControlView.initTrackSelectionAdapter(StyledPlayerControlView.java:1280)
        at com.google.android.exoplayer2.ui.StyledPlayerControlView.updateTrackLists(StyledPlayerControlView.java:1248)
        at com.google.android.exoplayer2.ui.StyledPlayerControlView.access$1800(StyledPlayerControlView.java:298)
        at com.google.android.exoplayer2.ui.StyledPlayerControlView$ComponentListener.onTracksChanged(StyledPlayerControlView.java:1813)
        at com.google.android.exoplayer2.ExoPlayerImpl$PlaybackInfoUpdate.lambda$run$4$ExoPlayerImpl$PlaybackInfoUpdate(ExoPlayerImpl.java:1425)
        at com.google.android.exoplayer2.-$$Lambda$ExoPlayerImpl$PlaybackInfoUpdate$sJrY7lA_vUJy5MdfV-ndTSxVTXI.invokeListener(Unknown Source:2)
        at com.google.android.exoplayer2.BasePlayer$ListenerHolder.invoke(BasePlayer.java:285)
        at com.google.android.exoplayer2.ExoPlayerImpl.invokeAll(ExoPlayerImpl.java:1491)
        at com.google.android.exoplayer2.ExoPlayerImpl.access$100(ExoPlayerImpl.java:56)
        at com.google.android.exoplayer2.ExoPlayerImpl$PlaybackInfoUpdate.run(ExoPlayerImpl.java:1422)
        at com.google.android.exoplayer2.ExoPlayerImpl.notifyListeners(ExoPlayerImpl.java:1321)
        at com.google.android.exoplayer2.ExoPlayerImpl.updatePlaybackInfo(ExoPlayerImpl.java:949)
        at com.google.android.exoplayer2.ExoPlayerImpl.handlePlaybackInfo(ExoPlayerImpl.java:913)
        at com.google.android.exoplayer2.ExoPlayerImpl.lambda$new$0$ExoPlayerImpl(ExoPlayerImpl.java:162)
        at com.google.android.exoplayer2.-$$Lambda$ExoPlayerImpl$c3953g1V6xPbTIQ95lEUPxO10qU.run(Unknown Source:4)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:209)
        at android.app.ActivityThread.main(ActivityThread.java:7021)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:486)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:872)
I/Process: Sending signal. PID: 9595 SIG: 9

@Samrobbo
Copy link
Contributor

Hi,
the TextTrackSelectionAdapter.init method has a checkNotNull on the subtitle button. Does your custom view have an image with an id of exo_subtitle?

@Samrobbo Samrobbo self-assigned this Sep 23, 2020
@ahmetberkinc
Copy link
Author

No i don't have an image named exo_subtitle. These are my custom_controller.xml codes.

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:layout_alignParentBottom="true">

    <FrameLayout
        android:id="@+id/previewFrameLayout"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/video_frame">

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

    </FrameLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@id/exo_position"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:includeFontPadding="false"
            android:paddingLeft="4dp"
            android:text="00:00"
            android:paddingRight="4dp"
            android:paddingBottom="4dp"
            android:textColor="#FFBEBEBE"
            android:textSize="14sp"
            android:textStyle="bold" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="2dp"
            android:layout_marginEnd="2dp"
            android:text="/"
            android:textColor="#CBCDC8" />

        <TextView
            android:id="@id/exo_duration"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:includeFontPadding="false"
            android:paddingLeft="4dp"
            android:layout_marginEnd="4dp"
            android:text="12:34"
            android:layout_weight="1"
            android:paddingRight="4dp"
            android:paddingBottom="4dp"
            android:textColor="#FFBEBEBE"
            android:textSize="14sp"
            android:textStyle="bold" />



    </LinearLayout>

    <com.github.rubensousa.previewseekbar.exoplayer.PreviewTimeBar
        android:id="@+id/exo_progress"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:layout_weight="1"
        app:previewAnimationEnabled="true"
        app:previewFrameLayout="@id/previewFrameLayout"/>

</LinearLayout>



<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal">

    <ImageButton
        android:id="@id/exo_rew"
        style="@style/ExoMediaButton.Rewind" />


    <ImageButton
        android:id="@id/exo_play"
        style="@style/ExoMediaButton.Play" />

    <ImageButton
        android:id="@id/exo_pause"
        style="@style/ExoMediaButton.Pause" />

    <ImageButton
        android:id="@id/exo_ffwd"
        style="@style/ExoMediaButton.FastForward" />


    <ImageButton
        android:id="@+id/exo_watch_again"
        android:layout_width="36dp"
        android:layout_height="36dp"
        android:background="@drawable/ic_replay" />

    <ImageButton
        android:id="@+id/exo_settings"
        android:layout_width="36dp"
        android:layout_height="36dp"
        android:layout_marginStart="12dp"
        android:background="@drawable/ic_settings" />



</LinearLayout>

This is StyledPlayerView xml part.

<com.google.android.exoplayer2.ui.StyledPlayerView
    android:id="@+id/player_view"
    app:controller_layout_id="@layout/custom_controller"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

I use a 3rd party library (https://github.com/rubensousa/PreviewSeekBar) to show the thumbnails in the video. Could it be due to this?

@Samrobbo
Copy link
Contributor

A patch will be available soon that fixes this issue, it appears to be down to a requirement in the StyledPlayerControlView that the layout has an image view with an exo_subtitle id. This requirement is being changed.

@ahmetberkinc
Copy link
Author

Thanks, I'm looking forward to the new update.

andrewlewis pushed a commit that referenced this issue Sep 30, 2020
Every other subtitleButton has an if not null check, but does not force non null.

Issue: #7962
PiperOrigin-RevId: 334124323
ojw28 pushed a commit that referenced this issue Oct 21, 2020
Every other subtitleButton has an if not null check, but does not force non null.

Issue: #7962
PiperOrigin-RevId: 334124323
@google google locked and limited conversation to collaborators Dec 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants