最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android使用vitamio插件實(shí)現(xiàn)視頻播放器

 更新時(shí)間:2019年04月18日 10:47:50   作者:ITzhongzi  
這篇文章主要為大家詳細(xì)介紹了Android使用vitamio實(shí)現(xiàn)視頻播放器,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

使用第三方的vitamio插件實(shí)現(xiàn)簡(jiǎn)易的播放器。vitamio版本(5.2.3)

官網(wǎng)地址:官網(wǎng)地址

效果展示

效果

項(xiàng)目結(jié)構(gòu)

代碼:

MainActivity

package com.example.www.app;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.vov.vitamio.Vitamio;

public class MainActivity extends ListActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
//    setContentView(R.layout.activity_main);

    Vitamio.isInitialized(getApplication());

    setListAdapter(new SimpleAdapter(this, getData(), R.layout.list_item_main, new String[]{"title"}, new int[]{R.id.main_list_item}));

  }

  protected List<Map<String, Object>> getData() {
    List<Map<String, Object>> myData = new ArrayList<Map<String, Object>>();
//    addItem(myData, "MediaPlayer", new Intent(this, MediaPlayerDemo.class));
    addItem(myData, "VideoView", new Intent(this, VideoViewDemo.class));
//    addItem(myData, "MediaMetadata", new Intent(this, MediaMetadataRetrieverDemo.class));
//    addItem(myData, "VideoSubtitle", new Intent(this, VideoSubtitleList.class));
//    addItem(myData, "VideoViewBuffer", new Intent(this, VideoViewBuffer.class));
    return myData;
  }

  protected void addItem(List<Map<String, Object>> data, String name, Intent intent) {
    Map<String, Object> temp = new HashMap<String, Object>();
    temp.put("title", name);
    temp.put("intent", intent);
    data.add(temp);
  }

  @SuppressWarnings("unchecked")
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    Map<String, Object> map = (Map<String, Object>) l.getItemAtPosition(position);
    Intent intent = (Intent) map.get("intent");
    startActivity(intent);
  }

}

VideoViewDemo

package com.example.www.app;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import io.vov.vitamio.MediaPlayer;
import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;

/**
 * @author Administrator
 * @name vitamioDemo
 * @class name:com.example.www.app
 * @class describe
 * @time 2019/4/10 8:59
 * @change
 * @chang time
 * @class describe
 */
public class VideoViewDemo extends AppCompatActivity {

  private VideoView mVideoView;
  private Button mPlayBtn;
  private EditText mPlayUrl;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mVideoView = (VideoView) findViewById(R.id.surface_view);
    mPlayBtn = (Button) findViewById(R.id.playBtn);
    mPlayUrl = (EditText) findViewById(R.id.video_url);
    mPlayBtn.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        playFunction(mPlayUrl.getText().toString());
      }
    });

    playFunction("");
  }

  void playFunction(String path){
    if(path.isEmpty()) {
      path = "http://gslb.miaopai.com/stream/3D~8BM-7CZqjZscVBEYr5g__.mp4";
    }

    mVideoView.setVideoPath(path);

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

        mp.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {
          @Override
          public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
            MediaController controller = new MediaController(VideoViewDemo.this);
            mVideoView.setMediaController(controller);
            // and set its position on screen
            controller.setAnchorView(mVideoView);
          }
        });
      }


    });
  }


}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".MainActivity">

  <EditText
    android:id="@+id/video_url"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginTop="28dp"
    android:layout_marginEnd="8dp"
    android:ems="10"
    android:hint="請(qǐng)輸入視頻地址"
    android:inputType="textPersonName"
    app:layout_constraintEnd_toStartOf="@+id/playBtn"
    app:layout_constraintHorizontal_bias="1.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

  <Button
    android:id="@+id/playBtn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="8dp"
    android:text="play"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="@+id/video_url"
    />

  <io.vov.vitamio.widget.VideoView
    android:id="@+id/surface_view"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.43"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/video_url" />

</android.support.constraint.ConstraintLayout>

list_item_main.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/main_list_item"
  android:layout_width="match_parent"
  android:layout_height="60dp"
  android:gravity="center_vertical"
  android:paddingStart="20dp"
  android:textAlignment="viewStart"
  android:textSize="24sp"
  android:textStyle="bold"
  tools:ignore="RtlCompat" />

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.www.app">

  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

  <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
      android:name="io.vov.vitamio.activity.InitActivity"
      android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
      android:launchMode="singleTop"
      android:theme="@android:style/Theme.NoTitleBar"
      android:windowSoftInputMode="stateAlwaysHidden" />
    <activity android:name=".MainActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <activity android:name=".VideoViewDemo"></activity>
  </application>

</manifest>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android中Activity常用功能設(shè)置小結(jié)(包括全屏、橫豎屏等)

    Android中Activity常用功能設(shè)置小結(jié)(包括全屏、橫豎屏等)

    這篇文章主要介紹了Android中Activity常用功能設(shè)置小結(jié)(包括全屏、橫豎屏等),以簡(jiǎn)單實(shí)例形式分析了Android實(shí)現(xiàn)全屏、豎屏及一直顯示等的技巧與注意事項(xiàng),需要的朋友可以參考下
    2015-10-10
  • Android監(jiān)聽(tīng)輸入法彈窗和關(guān)閉的實(shí)現(xiàn)方法

    Android監(jiān)聽(tīng)輸入法彈窗和關(guān)閉的實(shí)現(xiàn)方法

    用過(guò)ios的都知道ios上輸入法關(guān)閉的同時(shí)會(huì)自動(dòng)關(guān)閉輸入框,那么在android上如何實(shí)現(xiàn)監(jiān)聽(tīng)輸入法彈出和關(guān)閉呢?接下來(lái)通過(guò)本文給大家分享一種可靠的實(shí)現(xiàn)方式
    2016-11-11
  • Android開(kāi)發(fā)之圖形圖像與動(dòng)畫(huà)(四)AnimationListener簡(jiǎn)介

    Android開(kāi)發(fā)之圖形圖像與動(dòng)畫(huà)(四)AnimationListener簡(jiǎn)介

    就像Button控件有監(jiān)聽(tīng)器一樣,動(dòng)畫(huà)效果也有監(jiān)聽(tīng)器,只需要實(shí)現(xiàn)AnimationListener就可以實(shí)現(xiàn)對(duì)動(dòng)畫(huà)效果的監(jiān)聽(tīng),感興趣的朋友可以了解下啊,希望本文對(duì)你有所幫助
    2013-01-01
  • Flutter實(shí)現(xiàn)頁(yè)面路由及404路由攔截

    Flutter實(shí)現(xiàn)頁(yè)面路由及404路由攔截

    這篇文章介紹了Flutter實(shí)現(xiàn)頁(yè)面路由及404路由攔截的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2021-11-11
  • Android Toast使用的簡(jiǎn)單小結(jié)(推薦)

    Android Toast使用的簡(jiǎn)單小結(jié)(推薦)

    這篇文章主要介紹了Android Toast使用的簡(jiǎn)單小結(jié),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-03-03
  • Android中RecycleView與ViewPager沖突的解決方法及原理

    Android中RecycleView與ViewPager沖突的解決方法及原理

    這篇文章主要給大家介紹了關(guān)于Android中RecycleView與ViewPager沖突的解決方法及原理的相關(guān)資料,以及ViewPager嵌套R(shí)ecycleView卡頓問(wèn)題的處理方法,文中通過(guò)示例代碼介紹的非常狎昵,需要的朋友可以參考下
    2018-07-07
  • Android實(shí)現(xiàn)雷達(dá)View效果的示例代碼

    Android實(shí)現(xiàn)雷達(dá)View效果的示例代碼

    這篇文章主要介紹了Android實(shí)現(xiàn)雷達(dá)View效果,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-06-06
  • ANDROID應(yīng)用程序的混淆打包分享

    ANDROID應(yīng)用程序的混淆打包分享

    這篇文章主要介紹了ANDROID應(yīng)用程序的混淆打包,有需要的朋友可以參考一下
    2014-01-01
  • 利用Kotlin的協(xié)程實(shí)現(xiàn)簡(jiǎn)單的異步加載詳解

    利用Kotlin的協(xié)程實(shí)現(xiàn)簡(jiǎn)單的異步加載詳解

    這篇文章主要給大家介紹了關(guān)于利用Kotlin的協(xié)程實(shí)現(xiàn)簡(jiǎn)單的異步加載的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-03-03
  • Android 暫停和恢復(fù)Activity

    Android 暫停和恢復(fù)Activity

    在正常的應(yīng)用程序使用,前臺(tái)activity有時(shí)會(huì)被其他可視化組件遮擋,從而 造成activity的暫停。例如,當(dāng)一個(gè)半透明的activity打開(kāi)時(shí)(如在一個(gè)風(fēng)格對(duì)話框),以前的activity就暫停了。只要 activity仍然是部分可見(jiàn),但目前沒(méi)有獲得焦點(diǎn),它就依然處于暫停狀態(tài)
    2016-03-03

最新評(píng)論

大连市| 普兰店市| 大埔县| 灵台县| 南和县| 库车县| 霍邱县| 都兰县| 阜城县| 汶上县| 徐州市| 霍林郭勒市| 巴彦淖尔市| 明溪县| 黔江区| 时尚| 灌阳县| 抚州市| 昌都县| 九龙城区| 隆林| 绍兴县| 聊城市| 南皮县| 苏尼特右旗| 华宁县| 同心县| 岗巴县| 时尚| 太仓市| 和政县| 论坛| 准格尔旗| 手机| 武川县| 宣汉县| 漯河市| 苏州市| 凤山市| 米易县| 丽水市|