![【移動應(yīng)用開發(fā)技術(shù)】怎么在Android中使用vitamio插件實現(xiàn)一個視頻播放器_第1頁](http://file4.renrendoc.com/view/860e9cf312e4bf5d2c5cb17bfa9c53f2/860e9cf312e4bf5d2c5cb17bfa9c53f21.gif)
![【移動應(yīng)用開發(fā)技術(shù)】怎么在Android中使用vitamio插件實現(xiàn)一個視頻播放器_第2頁](http://file4.renrendoc.com/view/860e9cf312e4bf5d2c5cb17bfa9c53f2/860e9cf312e4bf5d2c5cb17bfa9c53f22.gif)
![【移動應(yīng)用開發(fā)技術(shù)】怎么在Android中使用vitamio插件實現(xiàn)一個視頻播放器_第3頁](http://file4.renrendoc.com/view/860e9cf312e4bf5d2c5cb17bfa9c53f2/860e9cf312e4bf5d2c5cb17bfa9c53f23.gif)
![【移動應(yīng)用開發(fā)技術(shù)】怎么在Android中使用vitamio插件實現(xiàn)一個視頻播放器_第4頁](http://file4.renrendoc.com/view/860e9cf312e4bf5d2c5cb17bfa9c53f2/860e9cf312e4bf5d2c5cb17bfa9c53f24.gif)
![【移動應(yīng)用開發(fā)技術(shù)】怎么在Android中使用vitamio插件實現(xiàn)一個視頻播放器_第5頁](http://file4.renrendoc.com/view/860e9cf312e4bf5d2c5cb17bfa9c53f2/860e9cf312e4bf5d2c5cb17bfa9c53f25.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
【移動應(yīng)用開發(fā)技術(shù)】怎么在Android中使用vitamio插件實現(xiàn)一個視頻播放器
這篇文章給大家介紹怎么在Android中使用vitamio插件實現(xiàn)一個視頻播放器,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。Android是一種基于Linux內(nèi)核的自由及開放源代碼的操作系統(tǒng),主要使用于移動設(shè)備,如智能手機(jī)和平板電腦,由美國Google公司和開放手機(jī)聯(lián)盟領(lǐng)導(dǎo)及開發(fā)。項目結(jié)構(gòu)代碼:MainActivitypackage
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);
}
}VideoViewDemopackage
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
=
"/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="/apk/res/android"
xmlns:app="/apk/res-auto"
xmlns:tools="/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="請輸入視頻地址"
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="/apk/res/android"
xmlns:tools="/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="/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="@sty
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 科技發(fā)展與學(xué)科教育的互促關(guān)系研究
- 科技教育編程教育的普及與推廣
- DB4453T 30-2025廣藿香組培苗生產(chǎn)技術(shù)規(guī)程
- DB35T 2232-2024海峽兩岸共通 火龍果生產(chǎn)技術(shù)規(guī)程
- 東莞企業(yè)勞動合同范本
- 個人貸款房屋抵押合同模板大全
- 業(yè)務(wù)經(jīng)營權(quán)轉(zhuǎn)讓合同
- 個人車位共有權(quán)買賣合同
- 臨時倉儲合同范本
- 兩人股權(quán)轉(zhuǎn)讓合同范本
- IEC-62368-1-差異分享解讀
- 如何當(dāng)好學(xué)校的中層干部
- SWITCH塞爾達(dá)傳說曠野之息-1.6金手指127項修改使用說明教程
- 2022-2023學(xué)年廣東省佛山市順德區(qū)高三(下)模擬英語試卷
- 節(jié)后復(fù)工培訓(xùn)內(nèi)容五篇
- GB/T 33322-2016橡膠增塑劑芳香基礦物油
- GA 1051-2013槍支彈藥專用保險柜
- 某水毀公路維修工程施工方案
- 家庭病房工作制度和人員職責(zé)
- 建設(shè)工程監(jiān)理合同示范文本GF-2018-0202
- 2022質(zhì)檢年終工作總結(jié)5篇
評論
0/150
提交評論