Open Videos and closing Videos in Sugarcube

I was wondering if anyone could help me with this situation. Use button#1 to open video #1 in a passage
and then being able to click button #2 and open Video #2 while closing video #1

Please specify version and format if asking for help, or apply optional tags above:
Twine Version: Twine 2
Story Format: Sugarcube 2

That isn’t enough information to figure out what’s happening.

We’ll need to see some sample code which demonstrates the problem before we can help.

I just created two buttons…and have the videos play on the buttons-I’d like to close “Flowers” when “Candy is open” and visa versa. I appreciate the help


<span id="Flowers">
<<button "Flowers">>
<<replace "#Flowers">><video src="assets/pics/places/home/hallway.webm" width="640" height="480" autoplay>
</video> <</replace>>
<</button>></span>

<span id="Candy">
<<button "Candy">>
<<replace "#Candy">> <video src="assets/pics/unique_npc/Gia/Gia_Lroom_1.webm" width="480" height="360" autoplay>
</video> <</replace>>
<</button>></span>

Sorry for the long delay in response. Hopefully this is what you were looking for:

<video id="vid" src="" autoplay style="height: 480px"></video>

<<button "Flowers">>
	<<run $("#vid").css({ height: 480 }).attr("src", "assets/pics/places/home/hallway.webm")>>
<</button>> <<button "Candy">>
	<<run $("#vid").css({ height: 360 }).attr("src", "assets/pics/unique_npc/Gia/Gia_Lroom_1.webm")>>
<</button>>

See the jQuery .css() and .attr() methods for details.

Also, note that some browsers don’t support WEBM video. I’d recommend using MP4/H.264 video instead (MP4 is the container format, and H.264 is the video compression format), since it’s much more widely supported.

Hope that helps! :grinning: