Currently, I am facing a certain issue. Unfortunately, I cannot provide a plunkr example as the image is sourced from a protected site and there are no open URLs available that constantly serve changing images. Additionally, I am unable to use a local animated image because it must be hosted on an external server in order to demonstrate the problem. Despite this limitation, the concept is quite simple.
The URL I am utilizing to display an image is being sent from a server that changes the image at a rate of approximately 3 frames per second.
<img ng-src="{{LoginData.url}}/cgi-bin/nph-zms?mode=jpeg&monitor={{monitorId}}&maxfps=3&buffer=1000&user={{LoginData.username}}&pass{{LoginData.password}}&rand={{rand}}" width="100%" style="backgroundimage:url('http://placeholder.com/placeholder.jpg');"/>
Here lies the issue: I would like to display a placeholder text or image in the following scenarios: a) The server may take some time to render the initial frame. b) Sometimes, the server fails to send any images at all
I want to prevent the screen from remaining blank in order to avoid causing confusion for the user.
The main problem I am encountering is that when the img-src loads, the screen turns white briefly before the actual images start streaming (scenario a) or remains blank for an extended period (scenario b).
I have tried different methods such as using a background image as shown in the code above. However, this only appears if there is an error in loading the img-src. In my case, it momentarily displays but then turns white once the img-src is encountered (until the server sends the images).
In addition, I have explored various techniques including the app.directive global image trap method mentioned in if a ngSrc path resolves to a 404, is there a way to fallback to a default?
The main challenge here is that my situation does not involve an image error. It seems like the server experiences delays without returning an HTTP error, causing the image window to turn white during that timeframe. I am looking to address this by overlaying text (or an image) on top of it until the actual images begin to arrive.
Thank you