溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Android中怎么實現(xiàn)多媒體播放功能

發(fā)布時間:2021-06-26 15:02:00 來源:億速云 閱讀:130 作者:Leah 欄目:移動開發(fā)

這篇文章將為大家詳細講解有關Android中怎么實現(xiàn)多媒體播放功能,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。

Android多媒體播放代碼:

import android.app.Activity;   import android.os.Bundle;   import android.view.View;   import android.view.View.OnClickListener;   import android.widget.Button;   import android.widget.VideoView;   public class VideoPlayer extends Activity   {   /**   Called when the activity is first created.   */ @Override   public void onCreate(Bundle icicle)   {   super.onCreate(icicle);   setContentView(R.layout.main);   final VideoView w =(VideoView)findViewById(R.id.vdoplayer);   Button cmdload = (Button)this.findViewById(R.id.cmd_load);   cmdload.setOnClickListener(new OnClickListener()  {   public void onClick(View arg0)   {   // TODO Auto-generated method stub   w.setVideoPath("/sdcard/android/kongfu.mp4");   }   }  );   Button cmdplay = (Button)this.findViewById(R.id.cmd_play);   cmdplay.setOnClickListener(new OnClickListener()  {   public void onClick(View arg0)   {   // TODO Auto-generated method stub   w.start();   }   }   );   Button cmdpause = (Button)this.findViewById(R.id.cmd_pause);   cmdpause.setOnClickListener(new OnClickListener()  {   public void onClick(View arg0)   {   // TODO Auto-generated method stub   w.pause();   }   }  );   }   }  main.xml:

Android多媒體播放實現(xiàn)代碼:

  1. < ?xml version="1.0" encoding="utf-8"?> 

  2. < LinearLayout xmlns:android=
    "http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

  3. < Button android:id="@+id/cmd_load" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:text="load" /> 

  4. < Button android:id="@+id/cmd_play" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:text="Play" /> 

  5. < Button android:id="@+id/cmd_pause" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:text="pause" /> 

  6. < VideoView android:id="@+id/vdoplayer" 
    android:layout_width="fill_parent" 
    android:layout_height="300px" /> 

  7. < /LinearLayout>  

關于Android中怎么實現(xiàn)多媒體播放功能就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

AI