編輯:關於android開發
1.在功能清單文件添加下面的意圖
<intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="rtsp" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="video/*" /> <data android:mimeType="application/sdp" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" /> <data android:mimeType="video/mp4" /> <data android:mimeType="video/3gp" /> <data android:mimeType="video/3gpp" /> <data android:mimeType="video/3gpp2" /> </intent-filter>
2.文件或者圖片浏覽器 //1.調起系統所有的播放-隱式意圖 Intent intent = new Intent(); intent.setDataAndType(Uri.parse("視頻播放地址"),"video/*"); context.startActivity(intent);
3.視頻播放器就會被調起並且播放
uri = getIntent().getData();//文件夾,圖片浏覽器,QQ空間
4.設置播放地址
videoview.setVideoURI(uri);
1_支持播放網絡視頻有緩沖效果
/** * 判斷是否是網絡資源 * @param uri * @return */ public boolean isNetUri(Uri uri) { boolean result = false; if (uri != null) { if (uri.toString().contains("http")|| uri.toString().contains("RTSP")|| uri.toString().contains("MMS")) { result = true; } else { result = false; } } return result; }
2_播放網絡視頻時候支持顯示緩存進度
//緩存進度的更新 if (isNetUri) { //只有網絡資源才有緩存效果 int buffer = videoview.getBufferPercentage();//0~100 int totalBuffer = buffer * seekbarVideo.getMax(); int secondaryProgress = totalBuffer / 100; seekbarVideo.setSecondaryProgress(secondaryProgress); } else { //本地視頻沒有緩沖效果 seekbarVideo.setSecondaryProgress(0); }
1_監聽卡並且提示
<!-- 卡的效果 --> <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ll_videobuffer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="#33000000" android:visibility="gone" android:gravity="center" android:orientation="horizontal"> <ProgressBar android:layout_width="30dp" android:layout_height="30dp" /> <TextView android:id="@+id/tv_netspeed" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:text="網速:20kb/s" android:textColor="@android:color/white" android:textSize="18sp" /> </LinearLayout>
代碼
在VideoView中定義監聽卡方法和監聽完成方法
//設置監聽卡2.3包括以後的版本才有 videoview.setOnInfoListener(new OnInfoListener() { @Override public boolean onInfo(MediaPlayer mp, int what, int extra) { switch (what) { case MediaPlayer.MEDIA_INFO_BUFFERING_START://當卡的時候和拖動卡的時候回調 // Toast.makeText(getApplicationContext(), "視頻卡了", 1).show(); player_buffer.setVisibility(View.VISIBLE); isBuffing = true; break; case MediaPlayer.MEDIA_INFO_BUFFERING_END://當卡的時候和拖動卡結束的時候回調 // Toast.makeText(getApplicationContext(), "視頻不卡了", 1).show(); player_buffer.setVisibility(View.GONE); isBuffing = false; break; } return true; } });
2_自定義監聽卡
//監聽卡 if (!isUseSystem) { if(videoview.isPlaying()){ int buffer = currentPosition - precurrentPosition; if (buffer < 500) { //視頻卡了 ll_buffer.setVisibility(View.VISIBLE); } else { //視頻不卡了 ll_buffer.setVisibility(View.GONE); } }else{ ll_buffer.setVisibility(View.GONE); } }
3_監聽拖動完成
//設置拖動完成 videoview.setOnSeekCompleteListener(new OnSeekCompleteListener() { @Override public void onSeekComplete(MediaPlayer mp) { if(isBuffing){ // TODO Auto-generated method stub player_buffer.setVisibility(View.GONE); } }
});
百度搜索:android 獲取當前網速
http://www.2cto.com/kf/201412/358191.html
/** * 得到當前的網速 *@paramcontext *@return */ public String getNetSpeed(Context context) { long nowTotalRxBytes = TrafficStats.getUidRxBytes(context.getApplicationInfo().uid)==TrafficStats.UNSUPPORTED ? 0 :(TrafficStats.getTotalRxBytes()/1024);//轉為KB; long nowTimeStamp = System.currentTimeMillis(); longspeed = ((nowTotalRxBytes - lastTotalRxBytes) *1000 / (nowTimeStamp - lastTimeStamp));//毫秒轉換 lastTimeStamp = nowTimeStamp; lastTotalRxBytes = nowTotalRxBytes; String speedStr = String.valueOf(speed) + " kb/s"; return speedStr; }
Android Studio關於SVN的相關配置及從SVN檢出項目,androidsvn一、安裝配置: 如圖,安裝時必須自定義選擇 command line 否則不會安裝
Android 幾種消息推送方案總結,android方案轉載請注明出處:http://www.cnblogs.com/Joanna-Yan/p/6241354.html
釋放Android的函數式能量(I):Kotlin語言的Lambda表達式,kotlinlambda原文標題:Unleash functional power on An
Android 手機衛士--home界面布局,android--home本文實現當從splash界面進入hone界面的時候,產生一種漸進淡入的動畫效果,在onCreate