import './index.scss';

import '../../sdk/adunion.min';
import { VideoPlayer } from '../../model/videoPlayerModel';
import clientParams from '../../model/exampleClient';
import vic from '../../model/exampleVic';
(() => {
  adunion.init(clientParams);

  let adspacePause = {
    width: 580,
    height: 326,
    maxAdCount: 1,
    maxDuration: 15,
    minCpm: 5,
  };

  const eventCallBack = (status) => {
    console.log(status);
    if (status === 'end') {
      document.getElementById('videoId').src =
        'http://152.136.58.123:8080/uftp_file/static/nunai_app/backup/tvadunion/testMedia/ttxs.mp4';
    }
  };

  window.onload = () => {
    console.log(document.getElementsByClassName('videoContent'));
    const videoPlayer = new VideoPlayer(
      document.getElementsByClassName('videoContent')[0]
    );
    adunion.fetchFrontAd(adspacePause, vic).then((frontAd) => {
      if(frontAd.status==1){
        frontAd.playAdVideo(0, 0, videoPlayer, eventCallBack);
      }
    });
  };
})();
