package com.nielsen.simplestandardandroid8200.models;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.Random;

/**
 * Created by abdul on 02/03/18.
 */

public class SDKMethods {

    public String url = "";
    JSONObject content = null;
    private int random = 0;

    //Loading Content URL
    public void setContentUrl(){

        url = "https://www.nielsenonlinesupport.com/colin/sdk3/assets/CanYouNameaCountry.mp4";
    }

    //Loading Ad URL
    public void setAdUrl(){

        int r = new Random().nextInt(15);
        String name = new String[] {"GeicoMeteor.mp4","Overflowing.mp4","Grandpa.mp4","Hyundai.mp4","Researcher.mp4","Walrus.mp4","GeicoMeteor.mp4","geicoHumpDay.mp4","GeicoPig.mp4","GeicoSpy.mp4","CleaningCrew.mp4","Geico2.mp4","Geico4.mp4","Geico5.mp4","GeicoSoapOpera.mp4"}[r];

        url = "https://www.nielsenonlinesupport.com/colin/sdk3/assets/" + name;

      //  url = "https://www.nielsenonlinesupport.com/colin/sdk3/assets/CanYouNameaCountry.mp4";//"http://www.nielseninternet.com/NWCC-3002/prog_index.m3u8";
    }

    //Loading DTVR URL
    public void setDtvrUrl(){

        url = "https://www.nielsenonlinesupport.com/assets/dtvr/RTVOD_(PC-FD)_C3/prog_index.m3u8";
    }

    //Loading Channel Info.
    public JSONObject loadChannelInfo(){

        JSONObject channel = null;
        try {

        channel = new JSONObject()
                .put("channelName", "ChannelTitle")
                .put("mediaURL", url);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return  channel;
    }

    //Loading content Data
    public JSONObject loadContentData(){

        url = "https://www.nielsenonlinesupport.com/colin/sdk3/assets/CanYouNameaCountry.mp4";
      //  url = "https://videocdn.bodybuilding.com/video/mp4/62000/62792m.mp4";//"http://www.nielseninternet.com/NielsenConsumer/prog_index.m3u8";
        random = new Random().nextInt() + 1099;

        JSONObject content = null;
        try {
            content = new JSONObject()
                    .put( "type","content")
                    .put( "assetid","C77664")
                    .put( "length","3600")
                    .put( "program","Sample Program")
                    .put( "segB","CustomSegmentValueB")
                    .put( "segC","segmentC")
                    .put( "title","S2,E3")
                    .put( "section","SectionName_" + random)
                    .put( "airdate","20190826 10:00:00")
                    .put( "isfullepisode","y")
                    .put( "adloadtype","2")
                    .put( "channelName","My Channel " + random)
                    .put( "pipMode","false");


        } catch (JSONException e) {
            e.printStackTrace();
        }

        return content;

    }

    //Loading PreRoll Ad data
    public JSONObject loadPreRollAdData(){

        JSONObject ad = null;
        try {

            ad = new JSONObject()
                    .put("type", "preroll")
                    .put("assetid", "AD1")
                    .put("title", "ADPreTitle");

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return ad;
    }

    //Loading DTVR data
    public JSONObject loadDtvr() {

        JSONObject dtvr = null;

        url = "https://www.nielsenonlinesupport.com/assets/dtvr/RTVOD_(PC-FD)_C3/prog_index.m3u8";

        try {

            dtvr = new JSONObject()
                    .put( "type","content")
                    .put("adModel", "1");

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return dtvr;
    }
}
