> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: Hiding a Video Player When There Is No Video to Play ## Article: Hiding a Video Player When There Is No Video to Play ## Article Link: https://dev.wix.com/docs/develop-websites/articles/code-tutorials/wix-editor-elements/hiding-a-video-player-when-there-is-no-video-to-play.md ## Article Content: # Velo Tutorial: Hiding a Video Player When There Is No Video to Play When you [connect](https://support.wix.com/en/article/cms-formerly-content-manager-displaying-collection-content-in-the-single-video-player) a Video Player element to a URL field in your collection, when the page is viewed, the player displays the associated video. If there is no URL for a given item, the video player displays the default video defined in its [Social Video Settings panel](https://support.wix.com/en/article/social-video-settings). If you'd rather not have any video play, you can automatically hide the Video Player when the item in your collection has no URL. This tutorial shows you how to do this using [Velo](https://dev.wix.com/docs/develop-websites/articles/get-started/about-developing-websites.md). This tutorial has 2 parts: * Instructions on how to get set up, including code you can copy and paste onto your page * An explanation of what each line of code does ### Instructions >**Before you begin:** > Make sure you have a [collection](https://support.wix.com/en/article/about-database-collections) that has a field of type "URL" where you store the video locations. There should be at least one item that has the URL field blank. 1. Add a [dataset](https://support.wix.com/en/article/about-datasets-and-connecting-data) to your page and connect it to your collection. 2. Add a Video Player and [connect](https://support.wix.com/en/article/cms-formerly-content-manager-displaying-collection-content-in-the-single-video-player) it to the URL field. 3. Open the code editor for your page. 4. Copy and paste the code below. ```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(); } }); }); ``` 1. Make sure to make these replacements: * _#myDataset_: the ID of the dataset * _video_: the [field ID](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-id-velo-by-wix-only) of the field in your collection that stores the video URL * _#videoPlayer_: the ID of the video player 2.  Preview your page for an item that does not have a URL and check that the video player is not displayed. >**Note:** Open the Properties & Events panel to see and update the IDs of your elements. ### Understanding the Code This section explains the main lines of the code. Each function has a link to its more detailed explanation in the [wix-dataset API](https://www.wix.com/velo/reference/wix-dataset.html). Line 1 calls the [`onReady()`](https://www.wix.com/velo/reference/$w.html#onReady) function. This defines the code that will run when the page is finished loading. $w.onReady(() => { Line 2 calls the [`dataset onReady()`](https://www.wix.com/velo/reference/wix-dataset/dataset/onready) function. This defines the code that will run after the dataset has loaded all the information for the current item. $w("#myDataset").onReady(() => { Line 4 defines a variable called `item` and then sets its value to be the object returned by the [`getCurrentItem()`](https://www.wix.com/velo/reference/wix-dataset/dataset/getcurrentitem) function. const item = $w("#myDataset").getCurrentItem(); This object contains the properties (fields) in the current item and their respective values. When a given field is blank in the current item, the object does not contain the corresponding property. Line 6 checks to see if the `item` variable from the previous line includes the `video` field, which is the field in the collection that stores the video URL. if (!item.video) { If the current item's `video` field is empty, then that field is not included in the object that was returned by `getCurrentItem()` in the previous line. Line 8 collapses the video player if the `video` field is blank. $w("#videoPlayer").collapse(); If the `video` field is not blank, then this line does not run. The video player remains visible to show the video at the URL defined in your collection for this item. You could also use the [`hide()`](https://dev.wix.com/docs/velo/velo-only-apis/$w/video/hide.md) function to hide the video player instead of collapsing it.