| | |
| | | */ |
| | | public class PlayVideoPreADFragment extends Fragment implements View.OnClickListener { |
| | | |
| | | private int AD_DURATION = 5; |
| | | |
| | | private final static String TAG = PlayVideoPreADFragment.class.getName(); |
| | | |
| | | private MediaView mediaView; |
| | |
| | | @Nullable |
| | | @Override |
| | | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | | |
| | | Bundle bundle = getArguments(); |
| | | if (bundle != null) { |
| | | AD_DURATION = bundle.getInt("skipDuration", 5); |
| | | } |
| | | |
| | | View root = LayoutInflater.from(getContext()).inflate(R.layout.item_video_detail_ad, null); |
| | | initView(root); |
| | |
| | | if (AdUtil.getAdType(getContext(), AdUtil.POSITION_VIDEO_PLAY_PRE) != AdUtil.AD_TYPE.gdt) |
| | | pid = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | |
| | | tv_skip.setText(AD_DURATION + "s后可跳过"); |
| | | // loadCSJ(CSJConstant.PLAY_VIDEO_PRE, videoAdListener); |
| | | loadGDT(setting.getGdtAppId(), pid, videoAdListener); |
| | | } |
| | |
| | | @Override |
| | | public void onVideoStart() { |
| | | Log.d(TAG, "onVideoStart"); |
| | | if (ad.getVideoDuration() / 1000 > 5) |
| | | remainTime = 5; |
| | | if (ad.getVideoDuration() / 1000 > AD_DURATION) |
| | | remainTime = AD_DURATION; |
| | | else |
| | | remainTime = ad.getVideoDuration() / 1000; |
| | | |
| | |
| | | tv_skip.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | Log.i(TAG, "点击跳过"); |
| | | if (mGDTAdData != null) |
| | | mGDTAdData.stopVideo(); |
| | | if (videoAdListener != null) |