Skip to content

Commit

Permalink
Add example with media player functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
stanmots committed Apr 6, 2017
1 parent 587ca0d commit ba80127
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package pl.droidsonroids.gif.sample;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.MediaController;

import pl.droidsonroids.gif.GifDrawable;
import pl.droidsonroids.gif.GifImageButton;

public class GifMediaPlayerFragment extends BaseFragment {

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.media_player, container, false);

final GifImageButton gib = (GifImageButton) view.findViewById(R.id.gifImageButton);
final GifDrawable gd = (GifDrawable) gib.getDrawable();
gd.setMaxFramesToRenderWhenSeeking(1);
final MediaController mc = new MediaController(getActivity());
mc.setMediaPlayer(gd);
mc.setAnchorView(gib);
gib.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mc.show();
}
});

return view;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ public Fragment getItem(int position) {
case 4:
return new AnimationControlFragment();
case 5:
return new HttpFragment();
return new GifMediaPlayerFragment();
case 6:
return new TexturePlaceholderFragment();
return new HttpFragment();
case 7:
return new GifTexImage2DFragment();
return new TexturePlaceholderFragment();
case 8:
return new AnimatedSelectorFragment();
return new GifTexImage2DFragment();
case 9:
return new AnimatedSelectorFragment();
case 10:
return new AboutFragment();
default:
throw new IndexOutOfBoundsException("Invalid page index");
Expand Down
Binary file added sample/src/main/res/drawable-nodpi/cat.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions sample/src/main/res/layout/media_player.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<pl.droidsonroids.gif.GifImageButton
android:id="@+id/gifImageButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:scaleType="fitCenter"
android:src="@drawable/cat"/>

</RelativeLayout>
1 change: 1 addition & 0 deletions sample/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<item>GIF in TextureView vs ImageView</item>
<item>GIF in ImageSpan</item>
<item>Basic animation control</item>
<item>GIF Media Player</item>
<item>GifTextureView and HTTP</item>
<item>GifTextureView placeholder</item>
<item>GifTexImage2D</item>
Expand Down

0 comments on commit ba80127

Please sign in to comment.