title = "channels"
url = "/channels/:slug"
layout = "default"
is_hidden = 0
==
<?php
function onStart(){
    $this["channel"] = $this->param('slug');
}
?>
==
<div class="auto_container">
    <div class="player-wrapper">
        <div>
            <video id="webtv-video" width="100%" height="100%" controls>Loading...</video>
        </div>
    </div>
</div>
<div class="auto_container">
    <div class="channel">
        <div class="channel__inner">
            <div class="chanel__items">
                <div class="items">
                    <div class="chan__pic1">
                        <a href="#" onclick="Altynasyr()">
                            <img src="{{ 'assets/images/altyn_asyr.png'|theme }}" alt="channel">
                        </a>
                    </div>
                </div>
                <div class="items">
                    <div class="chan__pic1">
                        <a href="#" onclick="Yaslyk()">
                            <img src="{{ 'assets/images/yaslyk.png'|theme }}" alt="channel">
                        </a>
                    </div>
                </div>
                <div class="items">
                    <div class="chan__pic1">
                        <a href="#" onclick="Miras()">
                            <img src="{{ 'assets/images/miras.png'|theme }}" alt="channel">
                        </a>
                    </div>
                </div>
                <div class="items">
                    <div class="chan__pic1">
                        <a href="#" onclick="Sport()">
                            <img src="{{ 'assets/images/turkmenistan_sport.png'|theme }}" alt="channel">
                        </a>
                    </div>
                </div>
                <div class="items">
                    <div class="chan__pic1">
                        <a href="#" onclick="Owaz()">
                            <img src="{{ 'assets/images/owaz.png'|theme }}" alt="channel">
                        </a>
                    </div>
                </div>
                <div class="items">
                    <div class="chan__pic1">
                        <a href="#" onclick="Ashgabat()">
                            <img src="{{ 'assets/images/ashgabat.png'|theme }}" alt="channel">
                        </a>
                    </div>
                </div>
            </div><!-- chanel__items -->
        </div> <!-- channel__inner -->
    </div><!-- channel -->
</div> <!-- container -->
<link rel="stylesheet" href="{{ 'assets/css/plyr.css'|theme }}"></link>

<script src="{{ 'assets/js/jquery.js'|theme }}"></script>
<script src="{{ 'assets/js/hls.min.js'|theme }}"></script>
<script src="{{ 'assets/js/plyr.js'|theme }}"></script>
<script>

    let channel = '{{ channel }}'

    switch(channel) {
      case "altyn_asyr":
            Altynasyr();
        break;
      case "yaslyk":
            Yaslyk();
        break;
        case "miras":
            Miras();
        break;
        case "turkmenistan_sport":
            Sport();
        break;
        case "owaz":
            Owaz();
        break;
        case "ashgabat":
            Ashgabat();
        break;
      default:
            Altynasyr();
    }

    function Altynasyr() {
    $(function() {

        let video_source = 'http://alpha.tv.online.tm/hls/ch001.m3u8';
        if (location.protocol == 'https:') {
            video_source = 'https://alpha.tv.online.tm/hls/ch001.m3u8';
        }
        let video = document.getElementById('webtv-video');
        if(Hls.isSupported()) {
        let hls = new Hls();
        hls.loadSource(video_source);
        hls.attachMedia(video);
        hls.on(Hls.Events.MANIFEST_PARSED,function() {
        video.play();
        });
        } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
        video.src = video_source;
        video.addEventListener('canplay',function() {
        video.play();
        plyr.setup(video);
        });
        }
    });
}

function Yaslyk() {
    $(function() {

        let video_source = 'http://alpha.tv.online.tm/hls/ch002.m3u8';
        if (location.protocol == 'https:') {
            video_source = 'https://alpha.tv.online.tm/hls/ch002.m3u8';
        }
        let video = document.getElementById('webtv-video');
        if(Hls.isSupported()) {
        let hls = new Hls();
        hls.loadSource(video_source);
        hls.attachMedia(video);
        hls.on(Hls.Events.MANIFEST_PARSED,function() {
        video.play();
        });
        } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
        video.src = video_source;
        video.addEventListener('canplay',function() {
        video.play();
        plyr.setup(video);
        });
        }
    });
}




function Miras() {
    $(function() {

        let video_source = 'http://alpha.tv.online.tm/hls/ch003.m3u8';
        if (location.protocol == 'https:') {
            video_source = 'https://alpha.tv.online.tm/hls/ch003.m3u8';
        }
        let video = document.getElementById('webtv-video');
        if(Hls.isSupported()) {
        let hls = new Hls();
        hls.loadSource(video_source);
        hls.attachMedia(video);
        hls.on(Hls.Events.MANIFEST_PARSED,function() {
        video.play();
        });
        } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
        video.src = video_source;
        video.addEventListener('canplay',function() {
        video.play();
        plyr.setup(video);
        });
        }
    });
}

function Sport() {
    $(function() {

        let video_source = 'http://alpha.tv.online.tm/hls/ch004.m3u8';
        if (location.protocol == 'https:') {
            video_source = 'https://alpha.tv.online.tm/hls/ch004.m3u8';
        }
        let video = document.getElementById('webtv-video');
        if(Hls.isSupported()) {
        let hls = new Hls();
        hls.loadSource(video_source);
        hls.attachMedia(video);
        hls.on(Hls.Events.MANIFEST_PARSED,function() {
        video.play();
        });
        } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
        video.src = video_source;
        video.addEventListener('canplay',function() {
        video.play();
        plyr.setup(video);
        });
        }
    });
}

function Owaz() {
    $(function() {

        let video_source = 'http://alpha.tv.online.tm/hls/ch005.m3u8';
        if (location.protocol == 'https:') {
            video_source = 'https://alpha.tv.online.tm/hls/ch005.m3u8';
        }
        let video = document.getElementById('webtv-video');
        if(Hls.isSupported()) {
        let hls = new Hls();
        hls.loadSource(video_source);
        hls.attachMedia(video);
        hls.on(Hls.Events.MANIFEST_PARSED,function() {
        video.play();
        });
        } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
        video.src = video_source;
        video.addEventListener('canplay',function() {
        video.play();
        plyr.setup(video);
        });
        }
    });
}

function Ashgabat() {
    $(function() {

        let video_source = 'http://alpha.tv.online.tm/hls/ch006.m3u8';
        if (location.protocol == 'https:') {
            video_source = 'https://alpha.tv.online.tm/hls/ch006.m3u8';
        }
        let video = document.getElementById('webtv-video');
        if(Hls.isSupported()) {
        let hls = new Hls();
        hls.loadSource(video_source);
        hls.attachMedia(video);
        hls.on(Hls.Events.MANIFEST_PARSED,function() {
        video.play();
        });
        } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
        video.src = video_source;
        video.addEventListener('canplay',function() {
        video.play();
        plyr.setup(video);
        });
        }
    });
}

function Turkmenistan() {
    $(function() {

        let video_source = 'http://alpha.tv.online.tm/hls/ch007.m3u8';

        if (location.protocol == 'https:') {
            video_source = 'https://alpha.tv.online.tm/hls/ch007.m3u8';
        }
        let video = document.getElementById('webtv-video');
        if(Hls.isSupported()) {
        let hls = new Hls();
        hls.loadSource(video_source);
        hls.attachMedia(video);
        hls.on(Hls.Events.MANIFEST_PARSED,function() {
        video.play();
        });
        } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
        video.src = video_source;
        video.addEventListener('canplay',function() {
        video.play();
        plyr.setup(video);
        });
        }
    });
}


</script>
