# Hiding a Video Player When There Is No Video to Play

**URL:** <https://forum.wixstudio.com/t/hiding-a-video-player-when-there-is-no-video-to-play/53811>\
**Category:** Ask the community\
**Tags:** question, wix-stores, code\
**Created:** [November 14, 2023, 6:43am UTC](https://forum.wixstudio.com/t/hiding-a-video-player-when-there-is-no-video-to-play/53811 "2023-11-14T06:43:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Diane1](https://avatars.discourse-cdn.com/v4/letter/d/df788c/32.png) [@Diane1](https://forum.wixstudio.com/u/Diane1)\
**Post date:** [November 14, 2023, 6:43am UTC](https://forum.wixstudio.com/t/hiding-a-video-player-when-there-is-no-video-to-play/53811/1 "2023-11-14T06:43:54Z")

</div>

I am trying to hide a videoplayer on a page when there is no video. It’s attached to a dataset that appears on the page. One of the fields displayed on the page is a video url. On some entries, there is no video, so I don’t want the videoplayer to appear . I have tried the code that appears on this page:

> **[Hiding a Video Player When There Is No Video to Play](https://dev.wix.com/docs/develop-websites/articles/getting-started/code-tutorials/hiding-a-video-player-when-there-is-no-video-to-play)**
>
> Velo Tutorial: Hiding a Video Player When There Is No Video to Play Visit the Velo by Wix website to onboard and continue learning. When you connect a Video Player element to a URL field in your collection, when the page is viewed, the player...

That is the suggestion from Wix helpdesk.

This is the code and it does not work:

```javascript
$w.onReady(() => {
    $w("#myDataset").onReady(() => {
  // Gets the current item properties and stores them in a variable called item
        const item = $w("#myDataset").getCurrentItem();
        // Checks if the current item has a value in the "video" field
        if (!item.video) {
        // Collapses the video player if there is no value for "video"
            $w("#videoPlayer").collapse();
        }
    });
});

```

I’ve tried and tried and nothing works. I’ve tried alternate code suggestions that don’t work.

What am I doing wrong. Some default video (skyline video) shows on the page on the entries where there is no video. I think that is the problem. Here is the page.

[https://gthompson272.wixsite.com/irss-usa/newsold](https://gthompson272.wixsite.com/irss-usa/newsold)

#code  
#question

---

<div class="post-metadata">

**Author:** ![noahlovell](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/noahlovell/32/118920_2.png) [@noahlovell](https://forum.wixstudio.com/u/noahlovell)\
**Post date:** [November 14, 2023, 12:19pm UTC](https://forum.wixstudio.com/t/hiding-a-video-player-when-there-is-no-video-to-play/53811/2 "2023-11-14T12:19:45Z")

</div>

It seems that on the page you shared you’re using a repeater, which would require slightly different code than the one shared above.

You’re probably looking for something similar to this

```javascript
$w.onReady(function () {
    $w("#datasetID").onReady(() => {
        $w('#repeaterID').onItemReady(($item, itemData, index) => {
            if (itemData.videoKey) {
                $item('#videoPlayerID').show();
            } else {
                $item('#videoPlayerID').hide();
            }
        })
    });
});

```

You’ll need to change out the `datasetID`, `repeaterID` and `videoPlayerID` for the IDs of the elements on your page.

You can find your element IDs here when you have selected them.  
 ![Screenshot 2023-11-14 at 12.16.41](https://us1.discourse-cdn.com/wix/original/3X/d/0/d0ae671cbb0224a15e447103bc5c5987f9bc1d26.png)

`itemData.videoKey` will also need updating to include the key of the video field in the database. When editing the field in the collection, you’ll find the key here:  
 ![Screenshot 2023-11-14 at 12.18.43](https://us1.discourse-cdn.com/wix/original/3X/e/3/e325860d4ac7924ebf4ebe869433b2ffa9dffe6f.png)

So for example, it might be `itemData.image` based on the key I have above.

Hope this helps 🙂 Good luck!
