A SeekBar suited for showing a preview of something. As seen in Google Play Movies.

Overview

PreviewSeekBar

A SeekBar suited for showing a video preview. As seen in Google Play Movies

Google Play Movies

PreviewSeekBar's sample

Build

Add the following to your app's build.gradle:

dependencies {
    // Base implementation with a standard SeekBar
    implementation 'com.github.rubensousa:previewseekbar:3.0.0'

    // ExoPlayer extension that contains a TimeBar. 
    // Grab this one if you're going to integrate with ExoPlayer
    implementation 'com.github.rubensousa:previewseekbar-exoplayer:2.11.4.0'
}

How to use with ExoPlayer

Add a custom controller to your PlayerView

<com.google.android.exoplayer2.ui.PlayerView
    android:id="@+id/playerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:controller_layout_id="@layout/exoplayer_controls"/>

Here's the sample's exoplayer_controls: https://github.com/rubensousa/PreviewSeekBar/blob/master/sample/src/main/res/layout/exoplayer_controls.xml

Change your TimeBar to a PreviewTimeBar

<FrameLayout
    android:id="@+id/previewFrameLayout"
    android:layout_width="@dimen/video_preview_width"
    android:layout_height="@dimen/video_preview_height"
    android:background="@drawable/video_frame">

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

</FrameLayout>

<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"
    app:previewAnimationEnabled="true"
    app:previewFrameLayout="@id/previewFrameLayout"/>

Place the View you want to use to display the preview in the FrameLayout above. In this example it's an ImageView but you can place any View inside. PreviewTimeBar will animate and show that FrameLayout for you automatically.

The FrameLayout must have the same parent as the PreviewTimeBar if you want the default animations to work

Create a PreviewLoader and pass it to the PreviewTimeBar

Note: A PreviewLoader is an interface that you need to implement yourself. This library isn't opinionated about how you actually show a preview. Check the sample code for an example on how it can be done using thumbnail sprites.

PreviewLoader imagePreviewLoader = ImagePreviewLoader();

previewTimeBar.setPreviewLoader(imagePreviewLoader);

In this project's sample, Glide is used with a custom transformation to crop the thumbnails from a thumbnail sprite.

GlideThumbnailTransformation

@Override
public void loadPreview(long currentPosition, long max) {
    GlideApp.with(imageView)
            .load(thumbnailsUrl)
            .override(GlideThumbnailTransformation.IMAGE_WIDTH,
                    GlideThumbnailTransformation.IMAGE_HEIGHT)
            .transform(new GlideThumbnailTransformation(currentPosition))
            .into(imageView);
}

Listen for scrub events to control playback state

When the user starts scrubbing the PreviewTimeBar, you should pause the video playback After the user is done selecting the new video position, you can resume it.

previewTimeBar.addOnScrubListener(new PreviewBar.OnScrubListener() {
    @Override
    public void onScrubStart(PreviewBar previewBar) {
        player.setPlayWhenReady(false);
    }

    @Override
    public void onScrubMove(PreviewBar previewBar, int progress, boolean fromUser) {
        
    }

    @Override
    public void onScrubStop(PreviewBar previewBar) {
        player.setPlayWhenReady(true);
    }
});

Customize the PreviewTimeBar

Available XML attributes:

<attr name="previewAnimationEnabled" format="boolean" />
<attr name="previewEnabled" format="boolean" />
<attr name="previewAutoHide" format="boolean" />
// Disables auto hiding the preview. 
// Default is true, which means the preview is hidden 
// when the user stops scrubbing the PreviewSeekBar
previewTimeBar.setAutoHidePreview(false);

// Shows the preview
previewTimeBar.showPreview();

// Hides the preview
previewTimeBar.hidePreview();

// Disables revealing the preview
previewTimeBar.setPreviewEnabled(false);

// Disables the current animation
previewTimeBar.setPreviewAnimationEnabled(false);

// Change the default animation
previewTimeBar.setPreviewAnimator(new PreviewFadeAnimator());

// Changes the color of the thumb
previewTimeBar.setPreviewThumbTint(Color.RED);

// Listen for scrub touch changes
previewTimeBar.addOnScrubListener(new PreviewBar.OnScrubListener() {
    @Override
    public void onScrubStart(PreviewBar previewBar) {
        
    }

    @Override
    public void onScrubMove(PreviewBar previewBar, int progress, boolean fromUser) {
        
    }

    @Override
    public void onScrubStop(PreviewBar previewBar) {
        
    }
});

// Listen for preview visibility changes
previewTimeBar.addOnPreviewVisibilityListener(new PreviewBar.OnPreviewVisibilityListener() {
    @Override
    public void onVisibilityChanged(PreviewBar previewBar, boolean isPreviewShowing) {
        
    }
});

How to use with a standard SeekBar

Setup your layout like the following:

<FrameLayout
  android:id="@+id/previewFrameLayout"
  android:layout_width="160dp"
  android:layout_height="90dp">

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

</FrameLayout>

<com.github.rubensousa.previewseekbar.PreviewSeekBar
  android:id="@+id/previewSeekBar"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_marginTop="24dp"
  android:max="800"
  app:previewFrameLayout="@id/previewFrameLayout"/>

Place the View you want to use to display the preview in the FrameLayout above. In this example it's an ImageView but you can place any View inside. PreviewSeekBar will animate and show that FrameLayout for you automatically.

The FrameLayout must have the same parent as the PreviewSeekBar if you want the default animations to work

Create a PreviewLoader and pass it to the PreviewSeekBar

PreviewSeekBar previewSeekBar = findViewById(R.id.previewSeekBar);

PreviewLoader imagePreviewLoader = ImagePreviewLoader();

previewSeekbar.setPreviewLoader(imagePreviewLoader);

Customization

Available XML attributes for styling:

<attr name="previewAnimationEnabled" format="boolean" />
<attr name="previewEnabled" format="boolean" />
<attr name="previewThumbTint" format="color" />
<attr name="previewAutoHide" format="boolean" />

Important note

This library is just an UI component for displaying previews. It doesn't handle generating thumbnail sprites from videos.

License

Copyright 2017 The Android Open Source Project
Copyright 2020 Rúben Sousa

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Issue: quite slow getting the image in the sample

    Issue: quite slow getting the image in the sample

    When I drag to seek, it's not immediate at all. It takes about 1-2 seconds to show the preview (tested on Nexus 5x). How come?

    Also not sure what the "local" does.

    question 
    opened by AndroidDeveloperLB 24
  • Some questions

    Some questions

    @rubensousa : Hi, first of all I wanted to congratulate you.

    Let's start with the questions:

    1. would it be possible to use the latest version of exoplayer? 2.8.1
    2. if I wanted to change the graphics of the exoplayer, would it be possible? if yes, how can I do?
    3. I tried to install the module but I did not understand, I also looked at the sample folder, but it seems that something escapes me.

    After creating a new project I have:

    • I opened the build.gradle file and installed the dependencies: implementation 'com.github.rubensousa: previewseekbar: 1.2' implementation 'com.github.rubensousa: previewseekbar-exoplayer: 2.6.0'

    from what I understand use glide, so I must also install Glide's addiction, right?

    opened by Angelk90 9
  • Sizes of each thumbnail

    Sizes of each thumbnail

    What is the size of each thumbnail so that it will fit in the preview, I tried to use this sample https://jwsupport.cdn.prismic.io/jwsupport/f39cd28a5474fcd4d1aee96d20f0452a945890f8_tooltipthumbs-sprite.jpg and it doesn't fit in some scene.

    help wanted 
    opened by ArcherEmiya05 5
  • Update dependencies and migrate to AndroidX

    Update dependencies and migrate to AndroidX

    This PR migrates the project to AndroidX and updates all dependencies to the latest stable versions.

    ExoPlayer introduced breaking changes with it's latest version and the code was updated to match the new APIs. This library cannot be used without these adjustments anymore and crashes immediately.

    I also did some other minor improvements whenever I saw something throughout the code.

    opened by rubengees 4
  • setPreviewColorTint does not work

    setPreviewColorTint does not work

    @rubensousa : I'm trying to set it, but it does not find the method.

             previewTimeBar = playerView.findViewById (R.id.exo_progress);
             previewTimeBar.setPreviewColorTint (R.color.colorPrimary);
    
    needs info 
    opened by Angelk90 4
  • PreviewSeekBar cannot be cast to com.google.android.exoplayer2.ui.TimeBar [Exoplayer 2.4.0]

    PreviewSeekBar cannot be cast to com.google.android.exoplayer2.ui.TimeBar [Exoplayer 2.4.0]

    Getting the following error as from exoplayer 2.4.0. i think they have change the control from a seekbar to a timebar ? The code was working well on Exoplayer 2.3.1

    E/AndroidRuntime: FATAL EXCEPTION: main java.lang.RuntimeException: android.view.InflateException: Binary XML file line #10: Error inflating class com.google.android.exoplayer2.ui.SimpleExoPlayerView com.github.rubensousa.previewseekbar.PreviewSeekBar cannot be cast to com.google.android.exoplayer2.ui.TimeBar

    these might help you https://google.github.io/ExoPlayer/doc/reference/com/google/android/exoplayer2/ui/DefaultTimeBar.html https://google.github.io/ExoPlayer/doc/reference/index.html?com/google/android/exoplayer2/ui/TimeBar.OnScrubListener.html

    Any fix plz ?

    opened by Khoosham 4
  • need to support SurfaceView

    need to support SurfaceView

    As you know, for playing dash + widevine content, we should use SurfaceView. I tried to integrate this library, however, It seems woking not well like this. Here is result for changing surface type to surface_view in your exoplayer_controls.xml. and same things happen in my application. image

    enhancement 
    opened by workspace 4
  • How to create the seekpreview thumbnail?

    How to create the seekpreview thumbnail?

    How do we create the seekpreview thumbnail? Do we have to screenshot every 5 minutes and join them to make a single image or is there any way to do so?

    opened by asrma7 3
  • rtl support

    rtl support

    I am trying to implement this seekbar in a rtl mode. Everything works fine but the thumbnail does not align with the seekbar button. The two are inverted: if the seekbar progress is left, the thumbnail is on the right, and vice versa.

    Here is what I am using: previewSeekBar.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);

    Any help would be appreciated, thanks!

    enhancement 
    opened by befora 3
  • intergrate PreviewSeekBar without EXOPlayer

    intergrate PreviewSeekBar without EXOPlayer

    hi ,your library is pretty cool, i want to use it in my own project without EXOPlayer, I've read READ_ME and haven't figured out how to do it ,you said Create a PreviewLoader and pass it to PreviewSeekBarLayout but i don't know where i should load preview to,should i pass PreviewSeekBarLayout instance to PreviewLoaderImpl ? any help is appreciated , thanks in advance

    help wanted 
    opened by fantasyado 2
  • Use with PlaybackControlView

    Use with PlaybackControlView

    Is it possible to use your PreviewSeekBar with Exoplayer's PlaybackControlView?

    Sample code:

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <com.google.android.exoplayer2.ui.AspectRatioFrameLayout
            android:id="@+id/aspect_ratio_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <SurfaceView
                android:id="@+id/surface_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:keepScreenOn="true" />
        </com.google.android.exoplayer2.ui.AspectRatioFrameLayout>
    
        <com.google.android.exoplayer2.ui.PlaybackControlView
            android:id="@+id/player_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </FrameLayout>
    
    opened by PerkmannM 2
  • How to integrate with VTT files

    How to integrate with VTT files

    I have vtt file that contains info about preview images:

    ` 01:43:40,000 --> 01:43:50,000 out02.jpg#xywh=292,120,146,60

    01:43:50,000 --> 01:44:00,000 out07.jpg#xywh=438,120,146,60

    01:44:00,000 --> 01:44:10,000 out03.jpg#xywh=584,120,146,60

    01:44:10,000 --> 01:44:20,000 out03.jpg#xywh=730,120,146,60

    01:44:20,000 --> 01:44:30,000 out07.jpg#xywh=876,120,146,60 ` ass you see each part of that contains info about preview image and its position.

    How can I integrate this vtt file with PreviewSeekBar. I saw your samples. It seems PreviewSeekBar takes one thumbnail URL to work with, But as you see I have a list of thumbnails in my vtt file.

    opened by MiladFaridnia 0
  • Is there anyway to make the seek bar less sensitive?

    Is there anyway to make the seek bar less sensitive?

    For a long movie , when my finger is shaking a bit, time is changed. it's too sensitive.

    Can we make the seek bar less sensitive and jump only when the time different is say 30+ seconds for example?

    opened by aviadavi 0
Releases(3.1.0)
Owner
Rúben Sousa
Rúben Sousa
Circular SeekBar view for Android

SeekArc What is a SeekArc? So what the heck is a SeekArc? Essentially it’s a SeekBar that has been wrapped around a circle. It acts like a SeekBar and

Neil Davies 870 Dec 10, 2022
Custom circular SeekBar (Circle, Semi-circle, and Ellipse) View/Widget for Android

CircularSeekBar Android CircularSeekBar Custom View/Widget This is a custom circular SeekBar. It can be used to create SeekBars that are: -Full Circle

Matt Joseph 462 Dec 19, 2022
A seekbar contains two cursor(left and right). Multiple touch supported.

RangeSeekbar A seekbar contains two cursor and support multi-touch. RangeSeekbar have left and right cursors, user can move cursor to make fliter. How

dolphinWang 283 Mar 28, 2022
Android circle seekbar widget inspired from: https://github.com/LarsWerkman/HoloColorPicker

Android HoloCircleSeekBar A Circle SeekBar inspired by Android Holo ColorPicker designed by Marie Schweiz and developed by Lars Werkman. How to integr

Jesus 232 Nov 10, 2022
A colorful SeekBar for picking color

ScreenShot: Attrs attr format default colorSeeds references colorBarPosition integer 0 alphaBarPosition integer 0 maxPosition integer 100 bgColor colo

Jack Fu 324 Dec 26, 2022
StartPointSeekBar is a custom view for the Android platform that makes it possible to have a SeekBar to have custom start point.

Forked/Inspired from https://code.google.com/p/range-seek-bar/ by [email protected] This solves the problem as described in http://

Gaurav Vashisth 142 Dec 29, 2022
A color picker seekbar for android.

ColorSeekBar A color picker seekbar for android. Download Use Gradle compile 'com.divyanshu.colorseekbar:colorseekbar:1.0.2' or Maven <dependency>

Divyanshu Bhargava 129 Nov 29, 2022
Ranger is custom view which able to act like android seekbar.

Ranger is custom view which able to act like android seekbar.

Enes Zor 3 Oct 17, 2021
It makes a preview from an url, grabbing all the information such as title, relevant texts and images. This a version for Android of my web link preview https://github.com/LeonardoCardoso/Link-Preview

LeoCardz Link Preview for Android It makes a preview from an url, grabbing all the information such as title, relevant texts and images. Visual Exampl

Leonardo Cardoso 420 Nov 19, 2022
It makes a preview from an url, grabbing all the information such as title, relevant texts and images. This a version for Android of my web link preview https://github.com/LeonardoCardoso/Link-Preview

LeoCardz Link Preview for Android It makes a preview from an url, grabbing all the information such as title, relevant texts and images. Visual Exampl

Leonardo Cardoso 420 Nov 19, 2022
Bego Chat is chat application in Kotlin and Firebase with the following features: last seen , user status like typing ,online and last seen with MVVM pattern and clean architecture

Compose ChatApp(Bego Chat) Bego Chat is Compose chat application in Kotlin and Firebase with the following features: sending all file types and abilit

Ahmed EL Bagory 5 Dec 20, 2022
Simple star rating system bars, a view similar to the ones seen on Google Playstore. ⭐🌟✨

RatingReviews RatingReviews (Rating and Reviews) is a widget and layout that adds a "Rating & Reviews" bar to your app, similar to the ones seen on Go

Taufiq Rahman 166 Nov 26, 2022
This application uses Google Play Services Vision library to scan barcodes. It uses Google's on device ML kit to scan for barcodes.

Barcode-Scanner This application showcases use of Google Play Services Vision library It uses Google's on device machine learning kit to scan for barc

Soumik 2 Apr 28, 2022
Movies App with Movies API

MoviesApp-Android ?? Movies app with MoviesApp API. Here i demonstrate the use of Modern Android development tools - (Kotlin, Architecture Components,

Arvind Meshram 17 Dec 12, 2022
New style for app design and Movies App with Movies API JetMaxMovies made in Jetpack Compose.😉😎

JetMaxMovie New style for app design and Movies App with Movies API JetMaxMovies made in Jetpack Compose. ?? ?? (Navigation Compose,Dagger-Hilt, Mater

Arvind Meshram 6 Jul 6, 2022
Movies-db-example - Sample Android application that loads movies data from a remote server

Movies Application Sample Android application that loads movies data from a remo

Bilal Ibrahim Hairab 0 Feb 8, 2022
Movies - Simple Application to show movies and advertisemnets

Movies Simple Application to show movies and advertisemnets Technologies This Ap

Reham Galal 0 Feb 3, 2022
Discover the most popular and top rated movies playing. Movies data fetched using tomdbapi.com API.

Movie-App A simple news app build using MVVM architecture. Discover the most popular and top rated movies playing. Movies data fetched using tomdbapi.

Mahmudul Hasan 5 Jan 3, 2023
Movies App represent a list of movies, list of categories, search about movie and Save movie in Room Database

What is this project? Movies App represent a list of movies, list of categories, search about movie and Save movie in Room Database Main Features Kotl

Ahmed Omara 23 Dec 13, 2022
*** WARNING: This library is no longer maintained *** An easy way to add a simple 'swipe-and-do-something' behavior to your `RecyclerView` items. Just like in Gmail or Inbox apps.

SwipeToAction An easy way to add a simple 'swipe-and-do-something' behavior to your RecyclerView items. Just like in Gmail or Inbox apps. Integration

Victor Calvello 223 Nov 16, 2022