@Override protected Boolean doInBackground(String... params) { // TODO Auto-generated method stub if (params.length < 3) return false; action = params[0]; if (ACTION_LIVE_CENTER.equals(action)) { return mEPG.live_center(params[1], params[2]); } else if (ACTION_LIVE_FT.equals(action)) { title = params[1]; vid = Integer.valueOf(params[2]); return ((itemList = mEPG.live_cdn(vid)) != null); } else { Log.e(TAG, "Java: unknown action: " + action); return false; } }
@Override protected void onPostExecute(Boolean result) { // TODO Auto-generated method stub if (result) { if (ACTION_LIVE_CENTER.equals(action)) { mAdapter = new MyPPTVLiveCenterAdapter(PPTVLiveCenterActivity.this, mEPG.getLiveStrm()); lv_tvlist.setAdapter(mAdapter); } else if (ACTION_LIVE_FT.equals(action)) { int best_ft = 0; int index = 0; int count = itemList.size(); for (int i = 0; i < count; i++) { CDNItem item = itemList.get(i); int ft = Integer.valueOf(item.getFT()); if (ft > best_ft) { best_ft = ft; index = i; } } CDNItem LiveItem = itemList.get(index); String play_url = null; if (mBwType == 0 || mBwType == 1) { short http_port = MediaSDK.getPort("http"); if (mBwType == 1) http_port = (short) MyHttpService.getPort(); play_url = PlayLinkUtil.getPlayUrl( vid, http_port, best_ft /*ft*/, 3 /*bw_type*/, mPlaybackTime.getPlaylinkSurfix()); } else if (mBwType == 2) { play_url = String.format( live_m3u8_url_fmt, LiveItem.getHost(), LiveItem.getInterval(), LiveItem.getDelay(), LiveItem.getRid(), LiveItem.getKey()); } else { Toast.makeText( PPTVLiveCenterActivity.this, "invalid bw_type " + mBwType, Toast.LENGTH_SHORT) .show(); return; } Intent intent = new Intent(PPTVLiveCenterActivity.this, PPTVPlayerActivity.class); Uri uri = Uri.parse(play_url); Log.i(TAG, "to play uri: " + uri.toString()); intent.setData(uri); intent.putExtra("title", title); intent.putExtra("ft", best_ft); intent.putExtra("best_ft", best_ft); Toast.makeText( PPTVLiveCenterActivity.this, String.format( "start to play %s, playlink %d, ft %d, size %d x %d, bitrate %d", title, vid, best_ft, LiveItem.getWidth(), LiveItem.getHeight(), LiveItem.getBitrate()), Toast.LENGTH_SHORT) .show(); startActivity(intent); } } else { Toast.makeText(getApplicationContext(), "获取列表失败", Toast.LENGTH_SHORT).show(); } }