欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

安卓飛機(jī)大戰(zhàn)(八)添加視頻文件

在安卓應(yīng)用里添加一個視頻文件,需要在res中添加一個名為raw(不能亂起)的文件夾,里面存放你要播放的視頻文件

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:空間域名、網(wǎng)絡(luò)空間、營銷軟件、網(wǎng)站建設(shè)、雙臺子網(wǎng)站維護(hù)、網(wǎng)站推廣。

代碼如下:

1.在lanyout中添加一個videoview

<?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="match_parent"
    android:background="#FFFFFF"
    android:orientation="vertical" >

    <VideoView
        android:id="@+id/video1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</LinearLayout>

2.在MainActivity中:

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import android.widget.VideoView;

public class MainActivity extends Activity {

    
    private VideoView video;
    private Button button1;
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);    
        setContentView(R.layout.begin_video);
        
                video=(VideoView)findViewById(R.id.video1);
                button1=(Button)findViewById(R.id.button1);
                Uri uri=Uri.parse("android.resource://com.example.agame/"+R.raw.startvideo);//獲得uri                video.setVideoURI(uri);//指定要播放的視頻

                video.requestFocus();讓video獲得焦點
                try{
                    video.start();//開始播放視頻
                }catch(Exception e){
                    e.printStackTrace();
                }
                video.setOnCompletionListener(new OnCompletionListener() {
                    
                    
                    public void onCompletion(MediaPlayer arg0) {
                        
                        finish();//結(jié)束
                    }
               });

}

這樣就可以播放視頻啦!!!

分享文章:安卓飛機(jī)大戰(zhàn)(八)添加視頻文件
路徑分享:http://chinadenli.net/article36/gogosg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化網(wǎng)站收錄網(wǎng)站內(nèi)鏈品牌網(wǎng)站設(shè)計標(biāo)簽優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作