android使用videoview播放視頻
public class Activity01 extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final VideoView videoView = (VideoView) findViewById(R.id.VideoView01);
Button PauseButton = (Button) this.findViewById(R.id.PauseButton);
Button LoadButton = (Button) this.findViewById(R.id.LoadButton);
Button PlayButton = (Button) this.findViewById(R.id.PlayButton);
// load
LoadButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0)
{
// videoView.setVideoPath("/sdcard/test.mp4");
videoView.setVideoPath("android.resource://com.homer/"+R.raw.china);
videoView.setMediaController(new MediaController(Activity01.this));
videoView.requestFocus();
}
});
// play
PlayButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0)
{
videoView.start();
}
});
// pause
PauseButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0)
{
videoView.pause();
}
});
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<VideoView
android:id="@+id/VideoView01"
android:layout_width="320px"
android:layout_height="240px" />
<Button
android:id="@+id/LoadButton"
android:layout_width="80px"
android:layout_height="wrap_content"
android:layout_x="30px"
android:layout_y="300px"
android:text="裝載" />
<Button
android:id="@+id/PlayButton"
android:layout_width="80px"
android:layout_height="wrap_content"
android:layout_x="120px"
android:layout_y="300px"
android:text="播放" />
<Button
android:id="@+id/PauseButton"
android:layout_width="80px"
android:layout_height="wrap_content"
android:layout_x="210px"
android:layout_y="300px"
android:text="暫停" />
</AbsoluteLayout>
- Android UniversalVideoView實(shí)現(xiàn)視頻播放器
- Android音視頻開發(fā)之VideoView使用指南
- Android自定義videoview仿抖音界面
- Android原生視頻播放VideoView的使用
- android多媒體類VideoView使用方法詳解
- Android編程實(shí)現(xiàn)VideoView循環(huán)播放功能的方法
- Android多媒體之VideoView視頻播放器
- Android VideoView類實(shí)例講解
- Android使用VideoView播放本地視頻和網(wǎng)絡(luò)視頻的方法
- Android中VideoView音視頻開發(fā)的實(shí)現(xiàn)
相關(guān)文章
android 獲取APP的唯一標(biāo)識(shí)applicationId的實(shí)例
下面小編就為大家分享一篇android 獲取APP的唯一標(biāo)識(shí)applicationId的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-02-02
android實(shí)現(xiàn)左右側(cè)滑菜單效果
這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)左右側(cè)滑菜單效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-10-10
Android使用Intent實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)
這篇文章主要為大家詳細(xì)介紹了Android使用Intent實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-10-10
Android中l(wèi)istview嵌套scrollveiw沖突的解決方法
這篇文章主要為大家詳細(xì)介紹了Android中l(wèi)istview嵌套scrollveiw沖突的解決方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-01-01
Android Scroll實(shí)現(xiàn)彈性滑動(dòng)_列表下拉彈性滑動(dòng)的示例代碼
下面小編就為大家分享一篇Android Scroll實(shí)現(xiàn)彈性滑動(dòng)_列表下拉彈性滑動(dòng)的示例代碼,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-01-01
Android開發(fā)使用Databinding實(shí)現(xiàn)關(guān)注功能mvvp
這篇文章主要為大家介紹了Android開發(fā)使用Databinding實(shí)現(xiàn)關(guān)注功能mvvp示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09
android的ListView點(diǎn)擊item使item展開的做法的實(shí)現(xiàn)代碼
這篇文章主要介紹了android的ListView點(diǎn)擊item使item展開的做法的實(shí)現(xiàn)代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-12-12
Android 5.0 實(shí)現(xiàn)水波擴(kuò)散效果
這篇文章主要為大家詳細(xì)介紹了Android 5.0 實(shí)現(xiàn)水波擴(kuò)散效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-01-01

