video bug fix
This commit is contained in:
parent
15aa09400f
commit
4e10494c64
|
@ -5,7 +5,7 @@
|
||||||
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
|
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
|
||||||
</configurations>
|
</configurations>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package org.nuclearfog.twidda.window;
|
package org.nuclearfog.twidda.window;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.media.MediaPlayer;
|
import android.media.MediaPlayer;
|
||||||
import android.media.MediaPlayer.OnInfoListener;
|
|
||||||
import android.media.MediaPlayer.OnPreparedListener;
|
import android.media.MediaPlayer.OnPreparedListener;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask.Status;
|
import android.os.AsyncTask.Status;
|
||||||
|
@ -37,8 +35,6 @@ import java.util.Locale;
|
||||||
|
|
||||||
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
|
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
|
||||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||||
import static android.media.MediaPlayer.MEDIA_INFO_BUFFERING_START;
|
|
||||||
import static android.media.MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START;
|
|
||||||
import static android.view.View.INVISIBLE;
|
import static android.view.View.INVISIBLE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static androidx.recyclerview.widget.LinearLayoutManager.HORIZONTAL;
|
import static androidx.recyclerview.widget.LinearLayoutManager.HORIZONTAL;
|
||||||
|
@ -46,7 +42,7 @@ import static org.nuclearfog.twidda.backend.ImageLoader.Mode.ONLINE;
|
||||||
import static org.nuclearfog.twidda.backend.ImageLoader.Mode.STORAGE;
|
import static org.nuclearfog.twidda.backend.ImageLoader.Mode.STORAGE;
|
||||||
|
|
||||||
|
|
||||||
public class MediaViewer extends AppCompatActivity implements OnImageClickListener, OnPreparedListener, OnInfoListener {
|
public class MediaViewer extends AppCompatActivity implements OnImageClickListener, OnPreparedListener, MediaPlayer.OnBufferingUpdateListener {
|
||||||
|
|
||||||
public static final String KEY_MEDIA_LINK = "link";
|
public static final String KEY_MEDIA_LINK = "link";
|
||||||
public static final String KEY_MEDIA_TYPE = "mediatype";
|
public static final String KEY_MEDIA_TYPE = "mediatype";
|
||||||
|
@ -155,6 +151,7 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIDEO:
|
case VIDEO:
|
||||||
|
video_progress.setVisibility(VISIBLE);
|
||||||
case ANGIF:
|
case ANGIF:
|
||||||
case VIDEO_STORAGE:
|
case VIDEO_STORAGE:
|
||||||
videoView.start();
|
videoView.start();
|
||||||
|
@ -181,16 +178,6 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onActivityResult(int reqCode, int returnCode, Intent intent) {
|
|
||||||
super.onActivityResult(reqCode, returnCode, intent);
|
|
||||||
if (reqCode == REQCODE_SD && returnCode == RESULT_OK) {
|
|
||||||
//storeImage(image); // TODO
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onImageClick(Bitmap image) {
|
public void onImageClick(Bitmap image) {
|
||||||
setImage(image);
|
setImage(image);
|
||||||
|
@ -220,15 +207,15 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
|
||||||
public void onPrepared(MediaPlayer mp) {
|
public void onPrepared(MediaPlayer mp) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ANGIF:
|
case ANGIF:
|
||||||
mp.setOnInfoListener(this);
|
mp.setOnBufferingUpdateListener(this);
|
||||||
mp.setLooping(true);
|
mp.setLooping(true);
|
||||||
mp.start();
|
mp.start();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIDEO:
|
case VIDEO:
|
||||||
|
mp.setOnBufferingUpdateListener(this);
|
||||||
case VIDEO_STORAGE:
|
case VIDEO_STORAGE:
|
||||||
videoController.show(0);
|
videoController.show(0);
|
||||||
mp.setOnInfoListener(this);
|
|
||||||
mp.seekTo(lastPos);
|
mp.seekTo(lastPos);
|
||||||
mp.start();
|
mp.start();
|
||||||
break;
|
break;
|
||||||
|
@ -237,18 +224,13 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onInfo(MediaPlayer mp, int infoCode, int extra) {
|
public void onBufferingUpdate(MediaPlayer mp, int percent) {
|
||||||
switch (infoCode) {
|
if (mp.isPlaying()) {
|
||||||
case MEDIA_INFO_BUFFERING_START:
|
if (video_progress.getVisibility() == VISIBLE)
|
||||||
video_progress.setVisibility(VISIBLE);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case MEDIA_INFO_VIDEO_RENDERING_START:
|
|
||||||
video_progress.setVisibility(INVISIBLE);
|
video_progress.setVisibility(INVISIBLE);
|
||||||
return true;
|
} else {
|
||||||
|
if (video_progress.getVisibility() == INVISIBLE)
|
||||||
default:
|
video_progress.setVisibility(VISIBLE);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,8 @@
|
||||||
android:id="@+id/video_load"
|
android:id="@+id/video_load"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center" />
|
android:layout_gravity="center"
|
||||||
|
android:visibility="invisible" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue