Android当Vitamio显示媒体控制器并且玩家的上边缘被削减时

时间:2016-09-13 12:46:09

标签: android vitamio

我正在使用Vitamio库进行歌曲直播,但面临UI问题。 Android当Vitamio显示媒体控制器并且玩家的上边缘被削减时

  

播放前:

enter image description here

  

播放时/播放后:

enter image description here

有任何建议如何避免视频视图从顶部触摸屏幕..

这是我的代码

  

activity_main.xml中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.android.vitamioexample.MainActivity"
    android:orientation="vertical"
    android:background="@color/player_bg"
    android:gravity="center_horizontal">
<LinearLayout
    android:id="@+id/player_linear_layout"
    android:layout_width="250dp"
    android:layout_height="250dp"
    android:orientation="vertical">
    <FrameLayout
        android:layout_width="250dp"
        android:layout_height="250dp">

        <io.vov.vitamio.widget.VideoView
            android:id="@+id/vitamio_videoView"
            android:layout_width="250dp"
            android:layout_height="250dp"

            android:visibility="visible"/>

    </FrameLayout>

</LinearLayout>

</LinearLayout>
  

mediacontroller.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="300dp"
    android:background="@color/transparent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:layout_marginBottom="@dimen/activity_vertical_margin"
    android:layout_marginLeft="@dimen/activity_horizontal_margin"
    android:layout_marginRight="@dimen/activity_horizontal_margin"
    android:layout_marginTop="@dimen/activity_vertical_margin"
    android:gravity="center_horizontal"
    android:layout_gravity="center_horizontal">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="30"
        android:orientation="horizontal"
        android:gravity="center_horizontal"
        android:layout_gravity="center_horizontal">

        <TextView
            android:id="@+id/mediacontroller_file_name"
            style="@style/MediaController_Text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:ellipsize="marquee"
            android:singleLine="true" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="30"
        android:orientation="vertical"
        android:gravity="center_horizontal"
        android:layout_gravity="center_horizontal">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <SeekBar
                android:id="@+id/mediacontroller_seekbar"
                style="@style/MediaController_SeekBar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"

                android:focusable="true"
                android:max="1000" />
            <!--android:layout_toLeftOf="@id/mediacontroller_time_total"-->
            <!--android:layout_toRightOf="@id/mediacontroller_time_current"-->
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >
            <TextView
                android:id="@+id/mediacontroller_time_current"
                style="@style/MediaController_Text"
                android:layout_width="0dp"
                android:layout_weight="50"
                android:layout_height="wrap_content"
                android:gravity="left"
                android:text="00:00"
                android:layout_marginLeft="5dp"
                />

            <TextView
                android:id="@+id/mediacontroller_time_total"
                style="@style/MediaController_Text"
                android:layout_width="0dp"
                android:layout_weight="50"
                android:layout_height="wrap_content"
                android:gravity="right"
                android:layout_marginRight="5dp"
                android:text="00:40"/>

        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="40"
        android:orientation="horizontal"
        android:gravity="center_horizontal"
        android:layout_gravity="center_horizontal">

        <ImageButton
            android:id="@+id/mediacontroller_play_pause"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginLeft="5dp"
            android:background="@drawable/mediacontroller_button"
            android:contentDescription="@string/mediacontroller_play_pause"
            android:src="@drawable/mediacontroller_pause" />



    </LinearLayout>


</LinearLayout>
  

MainActivity.java

public class MainActivity1 extends AppCompatActivity {


    private static final String TAG = "MainActivity";
    private String path;
    private VideoView mVideoView;
    private MediaController mMediaController;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (!LibsChecker.checkVitamioLibs(this))
            return;
        setContentView(R.layout.activity_main);
        mVideoView = (VideoView) findViewById(R.id.vitamio_videoView);
        path = "rtmp://10.10.3.11:1935/vod/mp3:01 - Aankhon Mein(MyMp3Song.Com)-1466059658085.mp3";

        mVideoView.setVideoPath(path);
        mMediaController = new MediaController(this);
        mVideoView.setMediaController(mMediaController);
        mVideoView.requestFocus();
        mMediaController.show();

        mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mediaPlayer) {
                mediaPlayer.setPlaybackSpeed(1.0f);
                mVideoView.start();

            }
        });


    }
}

0 个答案:

没有答案