Shut off video and close window

So how do I know if your code is actually working, i.e. helping me accomplish what I want?

Thatā€™s alright. Itā€™s usually best to reconsider adding comments as they tend to be a reaction to the code not being clear enough. Thatā€™s why the action professionals take is to strive to make the code clearer instead.

The video stops playing when you use the close link.

Well, I think my code is extremely easy to follow, but my comments make it even easier.

One thing I like about comments is that with an IDE itā€™s like you have two translationsā€¦ I can read my code in ā€œcodeā€ or I can read my code in ā€œEnglish (comments)ā€.

I would say that my heavy reliance on comments is a sign that I am not a professional coder. Then again, to me, it means that I am organized and take pride in removing ambiguity in my code for myself and others.

Since I am using a modal, I guess that wasnā€™t clearā€¦

In the past, when I started a video and then clicked Close, I guess I was switching my modal to a regular page view and the video somehow kept playing in the background even though it appears to be closed if you follow me?

I guess one way to confirm the video is closed is that I can no longer here it.

Another way is to verify that when you re-access the video it starts at t=0, right?

1 Like

@Paul_Wilkins,

I wanted to step back and explain the real reason for me looking to add Javascript.

Before going on, let me say that my mini photo-gallery website is done, and as you can imagine, itā€™s not easy for me to share my entire code-base, yet I suppose without seeing everything, one cannot always help troubleshoot at the late stages of development.

Nonetheless, I am having this issueā€¦

Thanks to Coothead, I learned a pretty spiffy way to take a normal HTML photo-gallery, and when you click on a thumbnail, instead of loading another page with an enlarged photo, he taught me how to use CSS to use the element :target feature so that I turn the div surrounding my thumbnail into a fixed (modal) window that then loads a larger photo.

(Yeah, Iā€™m sure there are a million ways to do this in Javascript, but not the path I want to go down right now.)

So this code that Coot shared with me is awesome, and it works perfect with photos. The issue is that late yesterday I realized that I forgot to take into account that my gallery also has videos in it.

i was able to get the videos to work with Cootā€™s code - he didnā€™t think it would work but it took like one line of CSS to make things work - but I have this nagging issueā€¦

In Firefox, at random times, when I load the gallery, I see "Transferring data from localhostā€¦ in the control bar as if my browser is spinning out.

Sometimes it is a false-positive, but often it means that when I click on a video thumbnail - really an image thumbnail - that the video wonā€™t load.

I was thinking that as I was testing things and opening/closing a million photos and videos, that maybe I wasnā€™t stopping the video before clicking ā€œCloseā€ and so while the video appeared to close, it was playing in the background and that if I did that enough it was freaking Firefox out?!

When I Google: ā€œTransferring data fromā€ bug this apears to be an issue with Firefox - still a bummer!!!

Anyways, I figured if I could use Javascript to close the video it might solve this issue.

Am grabbing some leftover pizza now before I pass out, and I will be heavily testing my site - with new code thanks to @Paul_Wilkins - in Firefox and Chrome tonight. But I still have this nagging feeling ths is an issue with my code.

I spent a lot of time reading my HTML, CSS, and PHP line-by-line last night and it looks okay, but who knows.

Not sure if any of this makes sense or if you have thoughts on it?

It seems that investigation is in order then. Starting from as simple an example as possible that demonstrates the problem, so that troubleshooting can easily show that the problem is resolved.

A new thread for investigating that will be useful too.

Iā€™ll dive into testing after I eat a bitā€¦

2 posts were split to a new topic: Waiting for available socketā€¦ in Firefox