Android SimpleVideoView

Simplify and improve video playback in Android.

License

License

Categories

Categories

IDE Development Tools
GroupId

GroupId

com.klinkerapps
ArtifactId

ArtifactId

simple_videoview
Last Version

Last Version

1.2.4
Release Date

Release Date

Type

Type

aar
Description

Description

Android SimpleVideoView
Simplify and improve video playback in Android.
Project URL

Project URL

https://github.com/klinker24/Android-SimpleVideoView
Source Code Management

Source Code Management

https://github.com/klinker24/Android-SimpleVideoView

Download simple_videoview

How to add to project

<!-- https://jarcasting.com/artifacts/com.klinkerapps/simple_videoview/ -->
<dependency>
    <groupId>com.klinkerapps</groupId>
    <artifactId>simple_videoview</artifactId>
    <version>1.2.4</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.klinkerapps/simple_videoview/
implementation 'com.klinkerapps:simple_videoview:1.2.4'
// https://jarcasting.com/artifacts/com.klinkerapps/simple_videoview/
implementation ("com.klinkerapps:simple_videoview:1.2.4")
'com.klinkerapps:simple_videoview:aar:1.2.4'
<dependency org="com.klinkerapps" name="simple_videoview" rev="1.2.4">
  <artifact name="simple_videoview" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.klinkerapps', module='simple_videoview', version='1.2.4')
)
libraryDependencies += "com.klinkerapps" % "simple_videoview" % "1.2.4"
[com.klinkerapps/simple_videoview "1.2.4"]

Dependencies

compile (1)

Group / Artifact Type Version
com.android.support » appcompat-v7 jar 25.1.1

Project Modules

There are no modules declared in this project.

Android SimpleVideoView

Screenshot

View the YouTube Demo, showcasing the libraries ability to be used within a ListView or RecyclerView.

Google's VideoView is great, and powerful, but I was not a fan at all of working with it. It was difficult, complex, overweight, and confusing. It also came with some key issues:

  • Bad aspect ratio and video stretching in some cases
  • Always took control of the AudioManager service (on Lollipop+)

This library looks to simplify the VideoView. It is just a wrapper of Android's MediaPlayer that addresses some of the issues. It is also very light-weight up until you start the actual playback, so, as long as you are smart about starting the videos, you could easily add this to a RecyclerView and use it for in-line video playback.

Features

  • Light-weight and easy to add into RecyclerView or ListView
  • Correct aspect ratio for videos so they don't get stretched
  • Configurations for whether or not you want to take control of the system's audio
  • Mute video content
  • Built in progress spinner

Note: This library does NOT contain any of the video controls at this time (play, pause, fast-forward, rewind), although it does expose the methods necessary for you to implement them on your own. This may be something I add in the future.

Installation

There are two ways to use this library:

As a Gradle dependency

This is the preferred way. Simply add:

dependencies {
    compile 'com.klinkerapps:simple_videoview:1.2.4'
}

to your project dependencies and run ./gradlew build or ./gradlew assemble.

As a library project

Download the source code and import it as a library project in Eclipse. The project is available in the folder library. For more information on how to do this, read here.

Example Usage

Functionality can be found in the example's MainActivity. It is very simple to play a video:

videoView.start("uri to video");

Defined in the XML layout:

<com.klinker.android.simple_videoview.SimpleVideoView
    android:id="@+id/video_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:loop="true"
    app:stopSystemAudio="true"
    app:muted="false"
    app:showSpinner="true"/>

You also need to cleanup after the video is done being viewed. I would recommend doing this in the Activity#onStop to aleviate some playback issues. If you do not call the SimpleVideoView#release function, there will be leakage everywhere, you will immediately be able to tell something is wrong thanks to the slowdowns it will cause!

@Override
public void onStop() {
    super.onStop();
    videView.release();
}

Example Usage within a List

For an example of using this in a RecyclerView, I recommend checking out my app, Talon for Twitter, and it's implementation on the GiffySearch. With this specific example, we do not automatically start the video when they are scrolled to, but, of course, this is totally possible and I prefer the auto-play way.

I will leave the auto-play implementation up to you all for now though. I cannot give away all my secrets, just the tools to do them. I may add an example for this in the future. Just make sure that you are releasing the videos correctly, as described above!

Contributing

Please fork this repository and contribute back using pull requests. Features can be requested using issues. All code, comments, and critiques are greatly appreciated.

Changelog

The full changelog for the library can be found here.

License

Copyright 2016 Luke Klinker

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.

Versions

Version
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0