마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

Videoview, 소리는 들리는데 화면이 안나오네요...

0 추천

안녕하세요. 

Custom VideoView를 이용하고있는데 아무리 해봐도 소리가 잘 나오는데 반해 화면은 검은색이더라구요;;

그래서 일반 VideoView로 바꿔봤는데도 동일한 현상이 나타나길래... 어떤 문제인지 감을 못잢겠더라구요...

구글에 좀 찾아보니 ZOrder 사용해서 해결하는 것 같은데 저는 해당 문제가 아닌 것 같아서요

java와 xml 소스 첨부하겠습니다. 

어떤 도움이라도 감사히 받겠습니다. 

.java

public class ExerciseFragment
        extends Fragment {
    private String uri = null;
    public MyVideoView videoView;
    private WebService ws = new WebService();
    private CustomMediaController localCustomMediaController = null;

    private VideoView videoView2 = null;

    public void onConfigurationChanged(Configuration paramConfiguration) {
        super.onConfigurationChanged(paramConfiguration);
        if (paramConfiguration.orientation == 2) {
            this.videoView.isFull = true;
        }
        while (paramConfiguration.orientation != 1) {
            return;
        }
        this.videoView.isFull = false;
    }

    public void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        paramBundle = getArguments();
        if (paramBundle != null) {
            this.uri = paramBundle.getString("uri");
        }
    }

    @Nullable
    public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle) {
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        View view = paramLayoutInflater.inflate(R.layout.fragment_correct_exercise, paramViewGroup, false);

        return view;
    }

    private VideoView mVideoView;

    public void onStart() {
        super.onStart();
        Uri localUri = null;

        if (!User.logout) {
            this.ws.callSearchDialog(getActivity(), "조회중입니다.");
            this.videoView = ((MyVideoView) getActivity().findViewById(R.id.videoView));
            localCustomMediaController = new CustomMediaController(getActivity());
            if (this.uri != null) {
                localUri = Uri.parse(this.uri);
            }
        }
        try {
            this.videoView.setVideoPath(this.uri);
            this.videoView.bringToFront();
            this.videoView.setMediaController(localCustomMediaController);
            this.videoView.requestFocus();
            this.videoView.setOnPreparedListener(new OnPreparedListener() {
                public void onPrepared(MediaPlayer paramAnonymousMediaPlayer) {
                    ExerciseFragment.this.videoView.seekTo(2);
                    ExerciseFragment.this.ws.removeSearchDialog();
                }
            });
            return;
        } catch (Exception localException) {
            localException.printStackTrace();
            this.ws.removeSearchDialog();
        }
    }

    public void onStop() {
        super.onStop();
    }

    class CustomMediaController extends MediaController {
        ImageButton mCCBtn;
        Context mContext;

        public CustomMediaController(Context context) {
            super(context);
            this.mContext = context;
        }

        private View makeCCView() {
            this.mCCBtn = new ImageButton(this.mContext);
            this.mCCBtn.setImageResource(R.drawable.icon_fullscreen_24);
            this.mCCBtn.setBackgroundColor(0);
            this.mCCBtn.setOnClickListener(new OnClickListener() {
                public void onClick(View paramAnonymousView) {
                    paramAnonymousView = ExerciseFragment.this.videoView;
                    if (ExerciseFragment.this.videoView.isFull) { // isFull =
                        ExerciseFragment.this.videoView.isFull = false;
                    } else {
                        ExerciseFragment.this.videoView.isFull = true;
                    }
                    ExerciseFragment.this.videoView.requestLayout();
                }
            });
            return this.mCCBtn;
        }

        public void setAnchorView(View paramView) {
            super.setAnchorView(paramView);
            FrameLayout.LayoutParams frameParams = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            frameParams.gravity = Gravity.RIGHT | Gravity.TOP;
            addView(makeCCView(), frameParams);
        }
    }
}

.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rl_exercise"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <MyVideoView
        android:id="@+id/videoView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerInParent="true" />

</RelativeLayout>

 

행인28 (480 포인트) 님이 2018년 1월 9일 질문
저도 media 재생 연습 때문에 videoview를 사용해봤는데 잘 안되서 SurfaceView를 사용하니 잘 되더라구요 구글링해서 한번 사용해보세요

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...