none
Retrieve Video from Sharepoint Asset library with Rowlimit RRS feed

  • Question

  • Hi,

    I have a sharepoint asset library with some folders.inside each folder i have some images and videos.

    Using javascript object model am retrieving images and videos and displaying in html div.

    I want to set rowlimit to items.But my code is working  and the video is getting retrieved if i dont set rowlimit in query.But if i set rowlimit only the video is not showing in html.no error message also displaying.

    Below is my code.

    function ViewAllFolders(folder)
        {
            var context = new SP.ClientContext.get_current();
            var web = context.get_web();
            var list = web.get_lists().getByTitle("Media Library");
           var query = SP.CamlQuery.createAllItemsQuery();
            
            var foldername='/Media Library/'+ folder +'';
            query.set_folderServerRelativeUrl(foldername);
            query.set_viewXml("<View><RowLimit>4</RowLimit></View>");
            allItems = list.getItems(query);
            context.load(allItems, 'Include(Title, ContentType,FileDirRef,FileLeafRef,FileRef,FileSystemObjectType,FSObjType)');
            context.executeQueryAsync(Function.createDelegate(this, this.success), Function.createDelegate(this, this.failed));
           
        }
      function success()
        {
            var listItemInfo = '';
            var listItemvideoInfo='';
    var fileUrls = "";
            var ListEnumerator = this.allItems.getEnumerator();
            while(ListEnumerator.moveNext())
            {
             var currentItem = ListEnumerator.get_current();
                var _contentType = currentItem.get_contentType();
             if (_contentType.get_name() == "Image")
                 {
                var File = currentItem.get_file();
                    var filename= currentItem.get_item("Title");;
                   
                        fileUrls = currentItem.get_item("FileRef")+"?RenditionID=7" + '\n';
                     
                         listItemInfo += '<figure class="col-sm-4 img-box">'+'<img src="'+ fileUrls +'" alt="Photo 1" class="img100"/>'+
                    '<figcaption class="img-title">'+ filename +'</figcaption>'+'</figure>';      
     
    }
    if(_contentType.get_name() =="Video Rendition")
    {

    var imgurl=currentItem.get_item("FileRef");


    listItemvideoInfo +='<div class="col-sm-4 img-box">'+ '<video controls="controls">'+'<source type="video/mp4" src="'+ imgurl +'">'+'</source>'+
                                      '<source type="video/webm" src="'+ imgurl +'">'+'</source>'+'</video>'+
                               '</div>';
    }

         }
            $(".ContainerPhoto").empty();
    $(".ContainerPhoto").html(listItemInfo.toString());
    $(".ContainerPhoto").show();
    $(".Containervideo").hide();


    $('#miscphoto').click(function ()
          {
     
            $(".ContainerPhoto").empty();
    $(".ContainerPhoto").html(listItemInfo.toString());
    $(".ContainerPhoto").show();
    $(".Containervideo").hide();


    });
    $('#miscvideo').click(function ()
    {
    $(".Containervideo").empty();
    $(".Containervideo").html(listItemvideoInfo.toString());
    $(".Containervideo").show();
    $(".ContainerPhoto").hide();
    });

     }
    function failed(sender, args)
     {
        alert("failed. Message:" + args.get_message());
     }
     
     

    Please reply with some suggestions.

    Regards,

    Poovi

    Friday, March 31, 2017 6:51 AM

Answers

  • Hi,

    I could able to resolve the issue by changing the query like below.

    query.set_viewXml("<View Scope='RecursiveAll'><RowLimit>4</RowLimit></View>");

    after this video also getting retrieved.

    Regards,

    poovi

    • Marked as answer by Poovi Friday, March 31, 2017 11:53 AM
    Friday, March 31, 2017 11:53 AM