video bug fix

This commit is contained in:
NudeDude 2019-06-05 12:49:18 +02:00
parent 4e10494c64
commit a8d5661394
3 changed files with 4 additions and 18 deletions

View File

@ -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_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" 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">

View File

@ -42,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, MediaPlayer.OnBufferingUpdateListener { public class MediaViewer extends AppCompatActivity implements OnImageClickListener, OnPreparedListener {
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";
@ -105,6 +105,7 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
case ANGIF: case ANGIF:
videoWindow.setVisibility(VISIBLE); videoWindow.setVisibility(VISIBLE);
video_progress.setVisibility(INVISIBLE);
Uri video = Uri.parse(link[0]); Uri video = Uri.parse(link[0]);
videoView.setOnPreparedListener(this); videoView.setOnPreparedListener(this);
videoView.setVideoURI(video); videoView.setVideoURI(video);
@ -207,13 +208,11 @@ 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.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.seekTo(lastPos); mp.seekTo(lastPos);
@ -223,18 +222,6 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
} }
@Override
public void onBufferingUpdate(MediaPlayer mp, int percent) {
if (mp.isPlaying()) {
if (video_progress.getVisibility() == VISIBLE)
video_progress.setVisibility(INVISIBLE);
} else {
if (video_progress.getVisibility() == INVISIBLE)
video_progress.setVisibility(VISIBLE);
}
}
public void setImage(Bitmap image) { public void setImage(Bitmap image) {
float ratio = image.getWidth() / (float) width; float ratio = image.getWidth() / (float) width;
int destHeight = (int) (image.getHeight() / ratio); int destHeight = (int) (image.getHeight() / ratio);

View File

@ -50,8 +50,7 @@
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>