A vertical line display right of the screen when playing video in VideoView
Asked Answered
C

0

6

I got an issue when playing video in VideoView ,a vertical line display in the video screen,the following code works fine in Samsung Galaxy TabPro,but vertical line appear right of the video screen when running in Android TV smart box.

activity_video_layout.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black">

    <VideoView
        android:id="@+id/video_activity_videoView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerInParent="true"
        android:background="@color/black" />
    <ProgressBar
        android:id="@+id/video_activity_progressBar"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true" />
</RelativeLayout>

VideoActivity.java

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_layout);
        mVideoView = (VideoView) findViewById(R.id.video_activity_videoView);
        mMc = new CustomMediaController(this);
        mMc.setFocusable(true);
        mVideoView.setMediaController(mMc);
        mVideoView.setOnFocusChangeListener(new OnFocusChangeListener() {                               
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    if (mMc != null) mMc.show(5000);
                } else {
                    if (mMc != null) mMc.hide();
                }
            }
        });

        mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener()  {
            @Override
            public void onPrepared(MediaPlayer mp) {                         
                if (Constant.DEBUG) Log.d(TAG, "Duration = " + mVideoView.getDuration() 
                        + ", Type = " + mType + ", mHasPermission = " + mHasPermission); 
                if (mTimer == null && mHasPermission == false) {
                    mTimer = new Timer(true);
                    mTimer.schedule(new timerTask(), 1000, 1000);
                }   

                mp.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {                   
                    @Override
                    public void onBufferingUpdate(MediaPlayer mp, int percent) {
                        if (Constant.DEBUG) Log.d(TAG, "percent = " + percent);
                        if (mIsReady == false) {
                            mIsReady = true;
                         mVideoView.setBackgroundColor(getResources().getColor(R.color.none));
                        ProgressBar progressBar = (ProgressBar) findViewById(R.id.video_activity_progressBar);
                        if (progressBar.getVisibility() != View.GONE) progressBar.setVisibility(View.GONE);
                        }
                    }
                });
            }
        });

        mType = getIntent().getIntExtra("type", Constant.PRG_TYPE_CHARGE);
        mHasPermission = getIntent().getBooleanExtra("permission", true);
        mId = getIntent().getStringExtra("id");
        String playTime = getIntent().getStringExtra("play_time");
        if (playTime != null) {
            mPlayTime = Integer.valueOf(playTime) * 1000;
            Log.d(TAG, "mPlayTime = " + mPlayTime);
        }
        mString = getIntent().getStringExtra("url");
        if (mString == null) {
            finish();
        } else {
            mVideoView.setVideoURI(Uri.parse(mString));
            if (mPlayTime != 0) {
                showContinueDialog();
            } else {
                mVideoView.requestFocus();
                mVideoView.start();     
            }
        }
    }

Any help would be appreciated. Thank you.

Campy answered 29/8, 2014 at 6:5 Comment(5)
have you tried testing it on other devices? or just with the two devices you mentioned?Pastore
thanks for your kindness! I tested in two smart box and one Samsung Galaxy TabPro,one of the smart box got this issue。Campy
Usually this kind of bugs are hardware dependent so it depends on the device used in testing. If you can test it in say at least 3 more devices then we can tell if this is a hardware dependent bug or a real software bug. Is it possible to test in more devices?Pastore
on first glance the code seems okay. can't run it now though, no IDE on my current device.Pastore
Yes you are right,I should test in more devices to see if this is a software bug. But I also used the original player in the smart box which has issue run our app to play the same video, the original player can play it without any issues.So I think this issue may caused by our app code.Campy

© 2022 - 2024 — McMap. All rights reserved.