本文實(shí)例講述了Android編程實(shí)現(xiàn)播放視頻的方法。分享給大家供大家參考,具體如下:
播放視頻文件其實(shí)并不比播放音頻文件復(fù)雜,主要是使用 VideoView 類來實(shí)現(xiàn)的。這個(gè) 類將視頻的顯示和控制集于一身,使得我們僅僅借助它就可以完成一個(gè)簡易的視頻播放器。 VideoView 的用法和 MediaPlayer 也比較類似,主要有以下常用方法:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
那么我們還是通過一個(gè)實(shí)際的例子來學(xué)習(xí)一下吧,新建 PlayVideoTest 項(xiàng)目,然后修改activity_main.xml 中的代碼,如下所示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <VideoView android:id="@+id/video_view" android:layout_width="match_parent" android:layout_height="wrap_content" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" > <Button android:id="@+id/play" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Play" /> <Button android:id="@+id/pause" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Pause" /> <Button android:id="@+id/replay" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Replay" /> </LinearLayout> </LinearLayout>
當(dāng)前文章:Android編程實(shí)現(xiàn)播放視頻的方法示例-創(chuàng)新互聯(lián)
分享URL:http://chinadenli.net/article16/dgpegg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈、網(wǎng)站收錄、Google、外貿(mào)建站、營銷型網(wǎng)站建設(shè)、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容