You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Override
protected void onPause() {
super.onPause();
Log.d(TAG, "Video On Pause……");
if (video_view != null && video_view.isPlaying()) {
mSeekPosition = video_view.getCurrentPosition();
Log.d(TAG, "Video On Pause mSeekPosition……" + mSeekPosition);
video_view.pause();
}
}
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
Log.d(TAG, "Video On Save Instance State Position=" + video_view.getCurrentPosition());
outState.putInt(SEEK_POSITION_KEY, mSeekPosition);
}
@Override
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
mSeekPosition = savedInstanceState.getInt(SEEK_POSITION_KEY);
Log.d(TAG, "Video On Restore Instance State Position=" + mSeekPosition);
}
private void initView() {
video_layout = findViewById(R.id.video_layout);
video_view = findViewById(R.id.video_view);
media_controller = findViewById(R.id.media_controller);
start = findViewById(R.id.start);
introduction = findViewById(R.id.introduction);
button_layout = findViewById(R.id.button_layout);
}
@Override
public void onScaleChange(boolean isFullscreen) {
this.isFullScreen = isFullscreen;
if (isFullscreen) {
ViewGroup.LayoutParams layoutParams = video_layout.getLayoutParams();
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
video_layout.setLayoutParams(layoutParams);
button_layout.setVisibility(View.GONE);
} else {
ViewGroup.LayoutParams layoutParams = video_layout.getLayoutParams();
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
layoutParams.height = this.cachedHeight;
video_layout.setLayoutParams(layoutParams);
button_layout.setVisibility(View.VISIBLE);
}
switchTitleBar(!isFullscreen);
}
private void switchTitleBar(boolean b) {
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
if (b) {
supportActionBar.show();
} else {
supportActionBar.hide();
}
}
}
@Override
public void onPause(MediaPlayer mediaPlayer) {
Log.d(TAG, "Video On Pause UniversalVideoView callback");
}
@Override
public void onStart(MediaPlayer mediaPlayer) {
Log.d(TAG, "Video On Start UniversalVideoView callback");
}
@Override
public void onBufferingStart(MediaPlayer mediaPlayer) {
Log.d(TAG, "Video On Buffering Start UniversalVideoView callback");
}
@Override
public void onBufferingEnd(MediaPlayer mediaPlayer) {
Log.d(TAG, "Video On Buffering End UniversalVideoView callback");
}
@Override
public void onBackPressed() {
if (this.isFullScreen) {
video_view.setFullscreen(false);
} else {
super.onBackPressed();
}
}
}
2022-02-16 19:25:06.702 6812-6812/com.example.helloandroid D/MediaPlayer: setSubtitleAnchor in MediaPlayer
2022-02-16 19:25:07.792 6812-6812/? D/AndroidRuntime: Shutting down VM
2022-02-16 19:25:07.793 6812-6812/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.helloandroid, PID: 6812
java.lang.NullPointerException: Attempt to invoke interface method 'void com.universalvideoview.UniversalMediaController$MediaPlayerControl.setFullscreen(boolean)' on a null object reference
at com.universalvideoview.UniversalMediaController$4.onClick(UniversalMediaController.java:499)
at android.view.View.performClick(View.java:5204)
at android.view.View$PerformClick.run(View.java:21153)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5647)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:745)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635)
2022-02-16 19:25:07.797 6812-6812/? I/Process: Sending signal. PID: 6812 SIG: 9
The text was updated successfully, but these errors were encountered:
MainActivity.java:
package com.example.helloandroid;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import com.universalvideoview.UniversalMediaController;
import com.universalvideoview.UniversalVideoView;
public class MainActivity16 extends AppCompatActivity implements UniversalVideoView.VideoViewCallback {
// cachedHeight = (int) (width * 3f / 4f);
// cachedHeight = (int) (width * 9f / 16f);
ViewGroup.LayoutParams videoLayoutParams = video_layout.getLayoutParams();
videoLayoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
videoLayoutParams.height = cachedHeight;
video_layout.setLayoutParams(videoLayoutParams);
video_view.setVideoPath(VIDEO_URL);
video_view.requestFocus();
}
});
}
}
2022-02-16 19:25:06.702 6812-6812/com.example.helloandroid D/MediaPlayer: setSubtitleAnchor in MediaPlayer
2022-02-16 19:25:07.792 6812-6812/? D/AndroidRuntime: Shutting down VM
2022-02-16 19:25:07.793 6812-6812/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.helloandroid, PID: 6812
java.lang.NullPointerException: Attempt to invoke interface method 'void com.universalvideoview.UniversalMediaController$MediaPlayerControl.setFullscreen(boolean)' on a null object reference
at com.universalvideoview.UniversalMediaController$4.onClick(UniversalMediaController.java:499)
at android.view.View.performClick(View.java:5204)
at android.view.View$PerformClick.run(View.java:21153)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5647)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:745)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635)
2022-02-16 19:25:07.797 6812-6812/? I/Process: Sending signal. PID: 6812 SIG: 9
The text was updated successfully, but these errors were encountered: