Exoplayer + remove useless lib
This commit is contained in:
parent
a428ae772e
commit
6e83958e0c
|
@ -88,7 +88,8 @@ dependencies {
|
|||
implementation 'com.github.GrenderG:Toasty:1.3.1'
|
||||
implementation 'com.elconfidencial.bubbleshowcase:bubbleshowcase:1.3.1'
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
implementation 'com.google.android.exoplayer:exoplayer:2.9.3'
|
||||
implementation 'com.google.android.exoplayer:exoplayer-core:2.9.3'
|
||||
implementation 'com.google.android.exoplayer:exoplayer-ui:2.9.3'
|
||||
implementation "com.github.TorrentStream:TorrentStream-Android:$torrentstreamVersion"
|
||||
implementation 'com.github.stom79:android-upload-service:3.4.2-Mastalab'
|
||||
implementation 'com.github.mabbas007:TagsEditText:1.0.5'
|
||||
|
|
|
@ -20,7 +20,6 @@ import android.content.SharedPreferences;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.RectF;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@ -33,17 +32,22 @@ import android.view.MotionEvent;
|
|||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.MediaController;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.github.chrisbanes.photoview.OnMatrixChangedListener;
|
||||
import com.github.chrisbanes.photoview.PhotoView;
|
||||
import com.google.android.exoplayer2.ExoPlayerFactory;
|
||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||
import com.google.android.exoplayer2.source.ExtractorMediaSource;
|
||||
import com.google.android.exoplayer2.ui.SimpleExoPlayerView;
|
||||
import com.google.android.exoplayer2.upstream.DataSource;
|
||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import com.gw.swipeback.SwipeBackLayout;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -77,7 +81,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
|
|||
private RelativeLayout loader;
|
||||
private ArrayList<Attachment> attachments;
|
||||
private PhotoView imageView;
|
||||
private VideoView videoView;
|
||||
private SimpleExoPlayerView videoView;
|
||||
private float downX;
|
||||
private int mediaPosition;
|
||||
MediaActivity.actionSwipe currentAction;
|
||||
|
@ -345,9 +349,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
|
|||
String url = attachment.getUrl();
|
||||
finalUrlDownload = url;
|
||||
videoView.setVisibility(View.GONE);
|
||||
if( videoView.isPlaying()) {
|
||||
videoView.stopPlayback();
|
||||
}
|
||||
|
||||
imageView.setVisibility(View.GONE);
|
||||
|
||||
if( attachment.getDescription() != null && !attachment.getDescription().equals("null")){
|
||||
|
@ -430,38 +432,36 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
|
|||
Uri uri = Uri.parse(file.getAbsolutePath());
|
||||
videoView.setVisibility(View.VISIBLE);
|
||||
|
||||
videoView.setVideoURI(uri);
|
||||
videoView.start();
|
||||
MediaController mc = new MediaController(MediaActivity.this);
|
||||
mc.setPadding(0, 0, 0, (int)Helper.convertDpToPixel(40, MediaActivity.this));
|
||||
videoView.setMediaController(mc);
|
||||
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
|
||||
@Override
|
||||
public void onPrepared(MediaPlayer mp) {
|
||||
loader.setVisibility(View.GONE);
|
||||
mp.start();
|
||||
mp.setLooping(true);
|
||||
}
|
||||
});
|
||||
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(),
|
||||
Util.getUserAgent(getApplicationContext(), "Mastalab"), null);
|
||||
|
||||
ExtractorMediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
|
||||
.createMediaSource(uri);
|
||||
|
||||
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(MediaActivity.this);
|
||||
videoView.setPlayer(player);
|
||||
loader.setVisibility(View.GONE);
|
||||
player.prepare(videoSource);
|
||||
player.setPlayWhenReady(true);
|
||||
fileVideo = file;
|
||||
downloadedImage = null;
|
||||
}else{
|
||||
videoView.setVisibility(View.VISIBLE);
|
||||
Uri uri = Uri.parse(url);
|
||||
videoView.setVideoURI(uri);
|
||||
videoView.start();
|
||||
MediaController mc = new MediaController(MediaActivity.this);
|
||||
mc.setPadding(0, 0, 0, (int)Helper.convertDpToPixel(40, MediaActivity.this));
|
||||
mc.setAnchorView(videoView);
|
||||
videoView.setMediaController(mc);
|
||||
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
|
||||
@Override
|
||||
public void onPrepared(MediaPlayer mp) {
|
||||
mp.start();
|
||||
mp.setLooping(true);
|
||||
}
|
||||
});
|
||||
videoView.start();
|
||||
|
||||
videoView.setVisibility(View.VISIBLE);
|
||||
|
||||
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(),
|
||||
Util.getUserAgent(getApplicationContext(), "Mastalab"), null);
|
||||
|
||||
ExtractorMediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
|
||||
.createMediaSource(uri);
|
||||
|
||||
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(MediaActivity.this);
|
||||
videoView.setPlayer(player);
|
||||
loader.setVisibility(View.GONE);
|
||||
player.prepare(videoSource);
|
||||
player.setPlayWhenReady(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -86,12 +86,13 @@
|
|||
android:textColor="#ffffffff"
|
||||
/>
|
||||
</FrameLayout>
|
||||
<VideoView
|
||||
android:layout_centerInParent="true"
|
||||
<com.google.android.exoplayer2.ui.SimpleExoPlayerView
|
||||
android:visibility="gone"
|
||||
android:id="@+id/media_video"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent"
|
||||
/>
|
||||
<ImageView
|
||||
android:visibility="gone"
|
||||
android:layout_margin="5dp"
|
||||
|
|
Loading…
Reference in New Issue