{"id":13396299,"url":"https://github.com/rubensousa/PreviewSeekBar","last_synced_at":"2025-03-13T22:32:13.763Z","repository":{"id":37431200,"uuid":"79966463","full_name":"rubensousa/PreviewSeekBar","owner":"rubensousa","description":"A SeekBar suited for showing a preview of something. As seen in Google Play Movies.","archived":false,"fork":false,"pushed_at":"2024-01-10T22:04:52.000Z","size":63625,"stargazers_count":3459,"open_issues_count":10,"forks_count":427,"subscribers_count":72,"default_branch":"master","last_synced_at":"2024-10-29T15:28:48.621Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubensousa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-24T23:52:44.000Z","updated_at":"2024-10-25T04:46:35.000Z","dependencies_parsed_at":"2023-02-14T06:45:17.010Z","dependency_job_id":"a9d4807b-bdde-4c86-80b0-fe2434bc8c43","html_url":"https://github.com/rubensousa/PreviewSeekBar","commit_stats":{"total_commits":216,"total_committers":5,"mean_commits":43.2,"dds":0.08796296296296291,"last_synced_commit":"cfd1adebf10d44d3c8efa66649850328c98fc02e"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubensousa%2FPreviewSeekBar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubensousa%2FPreviewSeekBar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubensousa%2FPreviewSeekBar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubensousa%2FPreviewSeekBar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubensousa","download_url":"https://codeload.github.com/rubensousa/PreviewSeekBar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243494334,"owners_count":20299801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T18:00:44.242Z","updated_at":"2025-03-13T22:32:10.392Z","avatar_url":"https://github.com/rubensousa.png","language":"Java","funding_links":[],"categories":["Index `(light-weight pages)`",":shamrock:  **Categories**","SeekBar","Index"],"sub_categories":[":books: Libraries"],"readme":"# PreviewSeekBar\n\nA SeekBar suited for showing a video preview. As seen in Google Play Movies\n\n### Google Play Movies\n\n\u003cimg src=\"screenshots/playmovies.gif\" width=600\u003e\u003c/img\u003e\n\n### PreviewSeekBar's sample\n\n\u003cimg src=\"screenshots/sample.gif\" width=600\u003e\u003c/img\u003e\n\n\n## Build\n\nAdd the following to your app's build.gradle:\n\n```groovy\ndependencies {\n    // Base implementation with a standard SeekBar\n    implementation 'com.github.rubensousa:previewseekbar:3.1.1'\n    // Media3 extension that contains a TimeBar. \n    implementation 'com.github.rubensousa:previewseekbar-media3:1.1.1.0'\n    // (Deprecated) ExoPlayer Extension that contains a TimeBar.\n    implementation 'com.github.rubensousa:previewseekbar-exoplayer:2.18.1.0'\n}\n```\n\n## How to use with Media3\n\n### Add a custom controller to your PlayerView\n\n```xml\n\u003candroidx.media3.ui.PlayerView\n    android:id=\"@+id/playerView\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    app:controller_layout_id=\"@layout/exoplayer_controls\"/\u003e\n```\n\nHere's the sample's exoplayer_controls: https://github.com/rubensousa/PreviewSeekBar/blob/master/sample/src/main/res/layout/exoplayer_controls.xml\n\n### Change your TimeBar to a PreviewTimeBar\n\n```xml\n\u003cFrameLayout\n    android:id=\"@+id/previewFrameLayout\"\n    android:layout_width=\"@dimen/video_preview_width\"\n    android:layout_height=\"@dimen/video_preview_height\"\n    android:background=\"@drawable/video_frame\"\u003e\n\n    \u003cImageView\n        android:id=\"@+id/imageView\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"/\u003e\n\n\u003c/FrameLayout\u003e\n\n\u003ccom.github.rubensousa.previewseekbar.exoplayer.PreviewTimeBar\n    android:id=\"@+id/exo_progress\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\"\n    android:layout_marginStart=\"8dp\"\n    android:layout_marginEnd=\"8dp\"\n    app:previewAnimationEnabled=\"true\"\n    app:previewFrameLayout=\"@id/previewFrameLayout\"/\u003e\n```\n\nPlace the View you want to use to display the preview in the FrameLayout above. \nIn this example it's an ImageView but you can place any View inside.\nPreviewTimeBar will animate and show that FrameLayout for you automatically.\n\n**The FrameLayout must have the same parent as the PreviewTimeBar if you want the default animations to work**\n\n### Create a PreviewLoader and pass it to the PreviewTimeBar\n\n**Note**: A PreviewLoader is an interface that you need to implement yourself. \nThis library isn't opinionated about how you actually show a preview.\nCheck the sample code for an example on how it can be done using thumbnail sprites.\n\n```java\nPreviewLoader imagePreviewLoader = ImagePreviewLoader();\n\npreviewTimeBar.setPreviewLoader(imagePreviewLoader);\n```\n\nIn this project's sample, Glide is used with a custom transformation to crop the thumbnails from a thumbnail sprite.\n\n[GlideThumbnailTransformation](https://github.com/rubensousa/PreviewSeekBar/blob/master/sample/src/main/java/com/github/rubensousa/previewseekbar/sample/glide/GlideThumbnailTransformation.java)\n\n```java\n@Override\npublic void loadPreview(long currentPosition, long max) {\n    GlideApp.with(imageView)\n            .load(thumbnailsUrl)\n            .override(GlideThumbnailTransformation.IMAGE_WIDTH,\n                    GlideThumbnailTransformation.IMAGE_HEIGHT)\n            .transform(new GlideThumbnailTransformation(currentPosition))\n            .into(imageView);\n}\n```\n\n### Listen for scrub events to control playback state\n\nWhen the user starts scrubbing the PreviewTimeBar, you should pause the video playback\nAfter the user is done selecting the new video position, you can resume it.\n\n```java\npreviewTimeBar.addOnScrubListener(new PreviewBar.OnScrubListener() {\n    @Override\n    public void onScrubStart(PreviewBar previewBar) {\n        player.setPlayWhenReady(false);\n    }\n\n    @Override\n    public void onScrubMove(PreviewBar previewBar, int progress, boolean fromUser) {\n        \n    }\n\n    @Override\n    public void onScrubStop(PreviewBar previewBar) {\n        player.setPlayWhenReady(true);\n    }\n});\n```\n\n### Customize the PreviewTimeBar\n\nAvailable XML attributes:\n\n```xml\n\u003cattr name=\"previewAnimationEnabled\" format=\"boolean\" /\u003e\n\u003cattr name=\"previewEnabled\" format=\"boolean\" /\u003e\n\u003cattr name=\"previewAutoHide\" format=\"boolean\" /\u003e\n```\n\n```java\n// Disables auto hiding the preview. \n// Default is true, which means the preview is hidden \n// when the user stops scrubbing the PreviewSeekBar\npreviewTimeBar.setAutoHidePreview(false);\n\n// Shows the preview\npreviewTimeBar.showPreview();\n\n// Hides the preview\npreviewTimeBar.hidePreview();\n\n// Disables revealing the preview\npreviewTimeBar.setPreviewEnabled(false);\n\n// Disables the current animation\npreviewTimeBar.setPreviewAnimationEnabled(false);\n\n// Change the default animation\npreviewTimeBar.setPreviewAnimator(new PreviewFadeAnimator());\n\n// Changes the color of the thumb\npreviewTimeBar.setPreviewThumbTint(Color.RED);\n\n// Listen for scrub touch changes\npreviewTimeBar.addOnScrubListener(new PreviewBar.OnScrubListener() {\n    @Override\n    public void onScrubStart(PreviewBar previewBar) {\n        \n    }\n\n    @Override\n    public void onScrubMove(PreviewBar previewBar, int progress, boolean fromUser) {\n        \n    }\n\n    @Override\n    public void onScrubStop(PreviewBar previewBar) {\n        \n    }\n});\n\n// Listen for preview visibility changes\npreviewTimeBar.addOnPreviewVisibilityListener(new PreviewBar.OnPreviewVisibilityListener() {\n    @Override\n    public void onVisibilityChanged(PreviewBar previewBar, boolean isPreviewShowing) {\n        \n    }\n});\n\n```\n\n## How to use with a standard SeekBar\n\n### Setup your layout like the following:\n\n```xml\n\u003cFrameLayout\n  android:id=\"@+id/previewFrameLayout\"\n  android:layout_width=\"160dp\"\n  android:layout_height=\"90dp\"\u003e\n\n  \u003cImageView\n      android:id=\"@+id/imageView\"\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"match_parent\" /\u003e\n\n\u003c/FrameLayout\u003e\n\n\u003ccom.github.rubensousa.previewseekbar.PreviewSeekBar\n  android:id=\"@+id/previewSeekBar\"\n  android:layout_width=\"match_parent\"\n  android:layout_height=\"wrap_content\"\n  android:layout_marginTop=\"24dp\"\n  android:max=\"800\"\n  app:previewFrameLayout=\"@id/previewFrameLayout\"/\u003e\n```\n\nPlace the View you want to use to display the preview in the FrameLayout above. \nIn this example it's an ImageView but you can place any View inside.\nPreviewSeekBar will animate and show that FrameLayout for you automatically.\n\n**The FrameLayout must have the same parent as the PreviewSeekBar if you want the default animations to work**\n\n### Create a PreviewLoader and pass it to the PreviewSeekBar\n\n```java\n\nPreviewSeekBar previewSeekBar = findViewById(R.id.previewSeekBar);\n\nPreviewLoader imagePreviewLoader = ImagePreviewLoader();\n\npreviewSeekbar.setPreviewLoader(imagePreviewLoader);\n```\n\n### Customization\n\nAvailable XML attributes for styling:\n\n```xml\n\u003cattr name=\"previewAnimationEnabled\" format=\"boolean\" /\u003e\n\u003cattr name=\"previewEnabled\" format=\"boolean\" /\u003e\n\u003cattr name=\"previewThumbTint\" format=\"color\" /\u003e\n\u003cattr name=\"previewAutoHide\" format=\"boolean\" /\u003e\n```\n\n## Important note\n\n**This library is just an UI component for displaying previews. It doesn't handle generating thumbnail sprites from videos.**\n\n\n## License\n\n    Copyright 2017 The Android Open Source Project\n    Copyright 2020 Rúben Sousa\n    \n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n    \n        http://www.apache.org/licenses/LICENSE-2.0\n    \n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubensousa%2FPreviewSeekBar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubensousa%2FPreviewSeekBar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubensousa%2FPreviewSeekBar/lists"}