日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Android中獲取手機支持的硬件解碼器類型以及對應的解碼器名稱

最近在做播放器項目,由于Android兼容性問題,硬解各種不兼容搞得項目組成員焦頭爛額,為了方便測試分析,我做了個小工具,來測試不同的Android手機支持的×××格式以及×××名稱。為防止,以后遺忘,在這里寫篇博客記錄之。

專注于為中小企業(yè)提供網(wǎng)站設(shè)計制作、成都網(wǎng)站制作服務(wù),電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)長豐免費做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了近1000家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。

MainActivity代碼:

@SuppressLint("NewApi")

public class MainActivity extends Activity implements OnClickListener {

private ListView decoder


List;

private ArrayList> datas = new ArrayList>();

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Button retrieve = (Button) findViewById(R.id.retrieve);

retrieve.setOnClickListener(this);

decoderList = (ListView) findViewById(R.id.decoderList);

}

@Override

public void onClick(View v) {

// MediaCodecInfo mediaCodecInfo = getSupportDecoder(

// MediaFormat.MIMETYPE_VIDEO_VP8, (Button) v);

getSupportDecoder((Button) v);

}

private MediaCodecInfo getSupportDecoder(Button button) {

button.setText("正在檢測...");

int numCodecs = MediaCodecList.getCodecCount();

HashMap map;

for (int i = 0; i < numCodecs; i++) {

MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);

map = new HashMap();

if (!codecInfo.isEncoder()) {

continue;

}

map.put("decoderName", codecInfo.getName());

String[] types = codecInfo.getSupportedTypes();

for (int j = 0; j < types.length; j++) {

if (map.containsValue(types[j])) {

continue;

} else {

map.put("decoderType", types[j]);

}

}

datas.add(map);

}

decoderList.setAdapter(new DecodeListAdapter(this, datas));

decoderList.setVisibility(View.VISIBLE);

button.setText("開始檢測");

return null;

}

}

斜體加粗部分是核心函數(shù)。

ListView適配器:

public class DecodeListAdapter extends BaseAdapter {

private ArrayList> decodeList;

private Context context;

public DecodeListAdapter(Context context,

ArrayList> decodeList) {

this.context = context;

this.decodeList = decodeList;

}

@Override

public int getCount() {

// TODO Auto-generated method stub

return decodeList.size();

}

@Override

public HashMap getItem(int position) {

// TODO Auto-generated method stub

return decodeList.get(position);

}

@Override

public long getItemId(int position) {

// TODO Auto-generated method stub

return position;

}

@Override

public View getView(int position, View convertView, ViewGroup parent) {

HashMap map = getItem(position);

ViewHolder vh = null;

if (convertView == null) {

convertView = LayoutInflater.from(context).inflate(

R.layout.decode_list_item, null);

vh = new ViewHolder();

vh.decoderName = (TextView) convertView

.findViewById(R.id.decoderName);

vh.decoderType = (TextView) convertView

.findViewById(R.id.decoderType);

convertView.setTag(vh);

} else {

vh = (ViewHolder) convertView.getTag();

}

if (position == 0) {

vh.decoderName.setText("×××名稱");

vh.decoderType.setText("×××類型");

} else {

vh.decoderName.setText(map.get("decoderName"));

vh.decoderType.setText(map.get("decoderType"));

}

return convertView;

}

private class ViewHolder {

TextView decoderName;

TextView decoderType;

}

}

activity_main.xml代碼:

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    android:paddingBottom="@dimen/activity_vertical_margin"

    android:paddingLeft="@dimen/activity_horizontal_margin"

    android:paddingRight="@dimen/activity_horizontal_margin"

    android:paddingTop="@dimen/activity_vertical_margin"

    tools:context="com.marller.decoderlist.MainActivity" >

   

        android:id="@+id/retrieve"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:text="開始檢測" />

   

        android:id="@+id/decoderList"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:cacheColorHint="#00000000"

        android:visibility="gone" />

decode_list_item.xml代碼:

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="horizontal"

    android:paddingBottom="@dimen/activity_vertical_margin"

    android:paddingTop="@dimen/activity_vertical_margin"

    tools:context="com.marller.decoderlist.MainActivity" >

   

        android:id="@+id/decoderName"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_weight="1.0"

        android:gravity="center"

        android:text="開始檢測" />

   

        android:id="@+id/decoderType"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:layout_weight="1.0"

        android:gravity="center" />


分享文章:Android中獲取手機支持的硬件解碼器類型以及對應的解碼器名稱
文章出自:http://www.dlmjj.cn/article/pgogci.html