自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Android多媒體播放功能的代碼解析

移動開發(fā) Android
我們在這篇文章中將會通過一段代碼示例為大家詳細解讀有關(guān)Android多媒體播放的操作技巧。大家可以以此為參考對象,來掌握這一應(yīng)用技巧。

我們曾經(jīng)在其他文章中通過對錄音以及錄像的實現(xiàn)方法具體講解過有關(guān)Android多媒體錄制的相關(guān)操作技巧。在這里我們將會為大家詳細介紹一下Android多媒體播放的應(yīng)用方式,以幫助大家對這方面的應(yīng)用知識有一個深刻的印象。

Android多媒體播放代碼:

  1. import android.app.Activity;   
  2. import android.os.Bundle;   
  3. import android.view.View;   
  4. import android.view.View.OnClickListener;   
  5. import android.widget.Button;   
  6. import android.widget.VideoView;   
  7. public class VideoPlayer extends Activity   
  8. {   
  9. /**   
  10. Called when the activity is first created.   
  11. */ @Override   
  12. public void onCreate(Bundle icicle)   
  13. {   
  14. super.onCreate(icicle);   
  15. setContentView(R.layout.main);   
  16. final VideoView w =(VideoView)findViewById(R.id.vdoplayer);   
  17. Button cmdload = (Button)this.findViewById(R.id.cmd_load);   
  18. cmdload.setOnClickListener(new OnClickListener()  
  19. {   
  20. public void onClick(View arg0)   
  21. {   
  22. // TODO Auto-generated method stub   
  23. w.setVideoPath("/sdcard/android/kongfu.mp4");   
  24. }   
  25. }  
  26. );   
  27. Button cmdplay = (Button)this.findViewById(R.id.cmd_play);   
  28. cmdplay.setOnClickListener(new OnClickListener()  
  29. {   
  30. public void onClick(View arg0)   
  31. {   
  32. // TODO Auto-generated method stub   
  33. w.start();   
  34. }   
  35. }   
  36. );   
  37. Button cmdpause = (Button)this.findViewById(R.id.cmd_pause);   
  38. cmdpause.setOnClickListener(new OnClickListener()  
  39. {   
  40. public void onClick(View arg0)   
  41. {   
  42. // TODO Auto-generated method stub   
  43. w.pause();   
  44. }   
  45. }  
  46. );   
  47. }   
  48. }  
  49. 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多媒體播放的具體代碼編寫方式就為大家介紹到這里。

【編輯推薦】

  1. Android target類型選擇技巧
  2. Android錄音失真具體解決方案
  3. Android屏幕大小相關(guān)技巧應(yīng)用指南
  4. Android多媒體錄制功能的實現(xiàn)方式介紹
  5. Android圖片大小調(diào)整動態(tài)實現(xiàn)方法
責(zé)任編輯:曹凱 來源: javaeye.com
相關(guān)推薦

2017-03-01 14:01:31

android多媒體音樂代碼

2010-01-27 15:15:13

Android多媒體錄

2013-12-17 13:29:04

iOS開發(fā)多媒體

2011-08-02 10:36:02

iOS開發(fā) SDK 多媒體

2009-12-25 17:02:33

WPF多媒體

2009-02-18 17:15:51

Fedora 10多媒體播放解決方案

2011-06-24 10:21:11

Qt phonon 多媒體

2021-09-13 15:15:18

鴻蒙HarmonyOS應(yīng)用

2022-01-11 17:58:13

Android 代碼操作系統(tǒng)

2013-08-28 16:08:19

多媒體Windows8.1

2010-01-27 13:52:15

Android多媒體框

2010-08-01 15:34:27

Android

2011-06-09 10:07:28

Qt phonon

2010-02-04 14:27:11

2010-06-30 10:38:05

2018-02-07 15:35:04

2018-05-25 14:37:58

2010-10-27 11:27:50

MAS視頻監(jiān)控H3C

2013-12-17 11:18:53

iOS開發(fā)多媒體API

2012-04-27 14:34:15

點贊
收藏

51CTO技術(shù)棧公眾號