Automatically adjust the size of embedded video streams within DIV elements

My application is quite simple, it displays four video streams in a quadrant layout. Users can double click on each video to switch to full-screen mode and then again to go back to the quadrant view, which all works perfectly.

The issue I'm facing involves determining the appropriate placement and size of the embedded objects within my DIVs. Ideally, I want the videos to occupy the entire space of each DIV regardless of how the user resizes their browser window.

Here is the CSS I am using:

.tl {
    position: absolute;
    top: 0;
    left: 0;
    right: 50%;
    bottom: 50%;
    background: white;
}
.tr {
    position: absolute;
    top: 0;
    left: 50%;
    right: 0;
    bottom: 50%;
    background: white;
 }
.bl {
    position: absolute;
    top: 50%;
    left: 0;
    right: 50%;
    bottom: 0;
    background: white;
}
.br {
    position: absolute;
    top: 50%;
    left: 50%;
    right: 0;
    bottom: 0;
    background: white;
}

HTML:

<body>
<div class='tr' id='vlc1'></div>
<div class='tl' id='vlc2'></div>
<div class='bl' id='vlc3'></div>
<div class='br' id='vlc4'></div>
</body>
</html>

And this is my JavaScript:

function play(instance, uri) {
    VLCobject.getInstance(instance).play(uri);
}

var player = null;
$(document).ready(function() {
    var mydiv = document.getElementById("tr");
    player = VLCobject.embedPlayer('vlc1', 400, 300, true);
    player.play("http://URL");
    player = VLCobject.embedPlayer('vlc2', 400, 300, true);
    player.play("http://URL");
    player = VLCobject.embedPlayer('vlc3', 400, 300, true);
    player.play("http://URL");
    player = VLCobject.embedPlayer('vlc4', 400, 300, true);
    player.play("http://URL");
});

I've included a jsfiddle link for reference: http://jsfiddle.net/AD4Vp/

It seems like I may need to dynamically adjust the size of the embedded videos. Although I have set fixed sizes (400,300), the videos appear left-oriented in each div, making it challenging to determine the optimal initial size. Any guidance on the best approach to solve this would be greatly appreciated.

Thank you!

Answer №1

After much thought, I finally devised a solution and eliminated jquery-vlc.js

I made changes to my HTML structure by enclosing the videos in another container:

New HTML Structure:

<div class='tr'><div class="vlccontent" id='vlc1'></div></div>
<div class='tl'><div class="vlccontent" id='vlc2'></div></div>
<div class='bl'><div class="vlccontent" id='vlc3'></div></div>
<div class='br'><div class="vlccontent" id='vlc4'></div></div>

The corresponding CSS is as follows:

.vlccontent {
   position: absolute;
   top: 0px;
   left: 0px;
   width: 100%;
   height: 100%;
}

In order to load the videos dynamically, I modified my JavaScript code to insert the embed statements using jQuery:

$(document).ready(function() {
    $('#vlc1').html('<embed type="application/x-vlc-plugin" toolbar="false" width="100%" height="100%" id="vlc_vid1" target="http://URL"></embed>');
    $('#vlc2').html('<embed type="application/x-vlc-plugin" toolbar="false" width="100%" height="100%" id="vlc_vid2" target="http://URL"></embed>');
    $('#vlc3').html('<embed type="application/x-vlc-plugin" toolbar="false" width="100%" height="100%" id="vlc_vid3" target="http://URL"></embed>');
    $('#vlc4').html('<embed type="application/x-vlc-plugin" toolbar="false" width="100%" height="100%" id="vlc_vid4" target="http://URL"></embed>');
});

These adjustments have greatly improved the functionality of the project.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with Vue JS router component: Unable to reuse JavaScript file containing webpack imports after switching routes

Hey, I'm facing a bit of a complex issue here, but I'll do my best to explain it clearly. Currently, I'm using the latest versions of Vue and Vue-Router in my application with webpack. The main component in question is called CP.vue & ...

Even after defining routes, Node Express continues to throw a 404 error

It appears that troubleshooting this issue may be challenging without providing more context. Here is the setup I have in a compact modular configuration: //index.js also known as the server ... // defining views path, template engine, and default layou ...

Can you explain the guidelines for overlapping CSS media queries?

When it comes to spacing out media queries accurately to prevent overlap, how should we approach it? Let's examine the following code as an example: @media (max-width: 20em) { /* styles for narrow viewport */ } @media (min-width: 20em) and (max ...

Filtered Owl Carousel

Hello everyone. Just wanted to mention that our English may not be perfect. I managed to filter with owl carousel by tweaking some codes I found online. It's working now, but I'd love for it to have an animated effect while filtering, like a fad ...

What is the best way to fill in fields on my webpage using a dropdown menu choice?

I'm exploring the world of ASP.NET MVC, AJAX, and jQuery for the first time. I'm attempting to populate some text boxes on my website based on a dropdown selection but it seems like the data isn't getting through. I suspect that the 'ch ...

JavaScript tutorial: Strategies for loading specific sections of a webpage initially

Many native apps, such as those on iOS, include a welcome page to keep users entertained while the app is loading. Currently, I am working on a Ruby on Rails web application (yes, it's a website!) I would like to incorporate a welcoming page into my ...

CSS - Mysterious Gaps Found in Div Block

Below is the code snippet I am currently working with: html { height: 100%; overflow: hidden; } body { height: 100%; color: #bdc3c7; font-family: Montserrat; background-color: #3E4651; } .nav { ...

Finding distinct values in a multidimensional array using JavaScript

When working with JavaScript, I created a multidimensional array using the following code: result.each(function(i, element){ init.push({ label : $(this).data('label'), value : $(this).val(), }); }); The resulting array in ...

The command "cordova" cannot be identified as a cmdlet

After running the npm command, Cordova was successfully installed on my system. The files and folders can be found in the directories %appdata%/npm and %appdata%/npm/node_modules. However, when attempting to use any Cordova command within the VS Code termi ...

How can specific times be disabled using Laravel-9 jQuery Timepicker?

$(document).ready(function(){ $('#time').timepicker({ timeFormat: 'h:mm a', interval: 60, minTime: '9', maxTime: '4:00pm', defaultTime: '9', startTime: '9:00', dyna ...

Issue: The observer's callback function is not being triggered when utilizing the rxjs interval

Here is a method that I am using: export class PeriodicData { public checkForSthPeriodically(): Subscription { return Observable.interval(10000) .subscribe(() => { console.log('I AM CHECKING'); this.getData(); }); } ...

"Yakov's slender typefaces are appearing incorrectly on the screen

I recently tried to incorporate Yakov thin fonts using CSS @font-face, but I noticed that the fonts appear quite different from the original ones. Any idea why this might be happening? Below is the code snippet I used: @font-face { font-family:' ...

Utilizing ajax to dynamically set the view of a leaflet map based on the input of a city

We are in the process of transitioning from gmaps to Leaflet. Setting up the map went smoothly, and the markers for all our stores are functioning as expected. I decided to use leaflet-search for this built-in feature that allows users to search for cities ...

Does Visual Studio Code support custom procedural import paths for JavaScript intellisense?

I am looking to implement JS (ESM) intellisense for vscode within the Firefox codebase for a specific distribution of Firefox. Within Firefox, I need to register modules in build scripts like moz.build and import them using paths such as "resource://gre/m ...

Displaying the data from duplicated table rows

Below is the table that was generated: https://i.sstatic.net/WIzz6.jpg This table was created using the following code: <table class="table table-bordered"> <thead> <tr> </tr> </thead> &l ...

"The website seems to be experiencing some technical difficulties on Firefox, but I have switched to

I attempted to reset the text area after sending a message with the code below: $(document).keypress(function (e) { if (e.which == 13) { e.preventDefault(); var $form = $('#f1'); $.ajax({ url: $form.attr( ...

I am currently transferring cross-site forgery tokens through jQuery strings. However, on the subsequent page, I create a fresh token which means their original tokens will no longer align

Alright, so I've been storing the tokens in a session: Session::get('token', 'randomtokenstringhere'); Every time a form is submitted, whether successfully or not, I generate a new token and update their session token. But let&ap ...

What causes the slash URL to behave differently than other URLs when running through the middleware of NodeJS?

When I type http://localhost:3000/product into the browser, why do I see output for both '/' and '/product'? Take a look at this code snippet below. const express = require('express'); const app = express(); // http://loca ...

Personalized File Upload Button

<input type="file"/> allows users to select a file from their local machine and upload it. I was looking for a way to have a customized button that opens the file browser dialog and initiates the upload process when clicked. You can see an example of ...

How to implement Google Tag Manager using the next/script component in Next.js 11?

Version 11 of Next.js recently introduced a new approach with the Script component offering various strategies. To avoid duplicate tags, it is advised to implement Google TagManager using the afterInteractive strategy. In my experimentation: // _app.js ...