Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Caglar 6 posts 78 karma points
    Mar 28, 2021 @ 19:30
    Caglar
    1

    I created video slider but not working correctly

    I'm using umbraco v8.12.1 and I created a video slider but my page refresh without nonstop. My code like that.

    if(carousel != null && carousel.Any()) 
    { 
    <div class="carousel slide" data-ride="carousel" id="@carouselId"> 
    <div class="carousel-inner" role="listbox">
    @{
            int slideCount = 0;
            foreach (var item in carousel.Where(x => x.IsVisible()))
            {
                 string youtubeUrl = item.Value<string>("youtubeVideoUrl");
                 <div class="item @(slideCount == 0 ? "active" : "")">
    
                       <iframe id="video_@slideCount" class="embed-player slide-media" src="http://www.youtube.com/embed/##video##? api=1&byline=0&portrait=0&title=0&background=1&mute=1&loop=0&autoplay=1" width="100%" height="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen onload="iframeDidLoad('@youtubeUrl','video_@slideCount')"></iframe>
    
                  </div>
                slideCount++;
           }
      }
    </div>
    <div>
        <a class="left carousel-control" href="#@carouselId" role="button" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i><span class="sr-only">Previous</span></a>
        <a class="right carousel-control" href="#@carouselId" role="button" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i><span class="sr-only">Next</span></a>
    </div>
    
        <ol class="carousel-indicators">
        @for (int i = 0; i < slideCount; i++)
        {
            <li data-target="#@carouselId" data-slide-to="@i" class="@(i == 0 ? "active" : null)"> 
            </li>
        }
        </ol>
    </div>
     }
    
    <script>
         function iframeDidLoad(videoUrl, id) {
    
         var youtubeLink = "http://www.youtube.com/embed/##videoId##api=1&byline=0&portrait=0&title=0&background=1&mute=1&loop=0&autoplay=1";
         var element = document.getElementById(id);
    
         var video_id = videoUrl.split('v=')[1];
         var ampersandPosition = video_id.indexOf('&');
         if (ampersandPosition != -1) {
             video_id = video_id.substring(0, ampersandPosition);
         }
    
        youtubeLink = youtubeLink.replace("##videoId##", video_id);
    
        document.getElementById(element.id).src = youtubeLink;
      }
    </script>
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies