interact with the play and pause functionalities of a video element generated by an object

I am encountering an issue while trying to play and stop a video tag created from an object tag. I keep getting an error message stating that play is not a function.

Below is my code:

<html>
<head>

<head/>
<body>
<object data="sample.mp4" name="VideoAdv" style="min-width: 100%; min-height: 100%;position:absolute;bottom:0;" >
    <param name="allowFullScreen" value="true" />
    <param name="loop" value="true" />
    <param name="controls" value="false" />
    <param name="autoplay" value="autoplay" />
<param name="Muted" value="true" />
</object>
<body/>
</html>

My jQuery script:

$("[name=media]").play();

I am using name=media because when I inspect the HTML in developer tools, I can see this

<object data="sample.mp4" name="VideoAdv" style="min-width: 100%; min-height: 100%;position:absolute;bottom:0;">
<html><head><meta name="viewport" content="width=device-width"></head><body>
<video controls="" autoplay="" name="media"><source src=".../sample.mp4" type="video/mp4"></video></body></html>
    <param name="allowFullScreen" value="true">
    <param name="loop" value="true">
    <param name="controls" value="false">
    <param name="autoplay" value="autoplay">
<param name="Muted" value="true">
</object>

How can I resolve the issue of playing and stopping the video (none of the params that I have set seem to be working)?

My main goal is to display both a video and an image or sequence of images just by changing the name attribute without having to modify the JavaScript or HTML code. Is there any other way to achieve this?

Answer №1

Give this a try and see if it works

<video width="640" height="480" controls>
  <source src=".../example.mp4" type="video/mp4">
  <source src=".../example.ogg" type="video/ogg">
  Your browser may not support the video tag.
</video>

Answer №2

Take a look at this code snippet. It solely relies on a YouTube video for its data.

<html>
    <body>
        <object data="https://www.youtube.com/v/tgbNymZ7vqY" name="VideoAdv" style="min-width: 100%; min-height: 100%;position:absolute;bottom:0;" >
            <param name="allowFullScreen" value="true" />
            <param name="loop" value="true" />
            <param name="controls" value="false" />
            <param name="autoplay" value="autoplay" />
            <param name="Muted" value="true" />
        </object>
    <body/>
</html>

https://jsfiddle.net/tro4f8zh/

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

Ryan Fait's Code for Creating a Responsive Sticky Footer Height

There are quite a few queries regarding Ryan Fait's sticky footer, but I urge you not to dismiss this one immediately! My goal is to have a footer with a dynamically sized height that sticks to the bottom of the page. Ryan Fait suggests wrapping all ...

Image positioned above the text in the mobile layout following the text

Can the layout be adjusted so that on desktop, the image is on the right and text on the left in the lower box, but on mobile, the image appears above the text? https://i.sstatic.net/hbPxa.png I understand that placing the image tag after the text tag in ...

Maintaining the order of elements in Angular's insertion process

I am currently facing an issue with my HTML fragment that iterates over a key and value collection. Everything works perfectly when I insert values into an object and iterate through it using the HTML fragment. However, in order to maintain a specific key ...

Strategies for submitting an AJAX form using the ENTER key from a textarea in Ruby on Rails

I'm currently working on a Ruby On Rails 2.3.8 project and I need assistance with enabling the submission of a remote_form_for when users hit the ENTER key while inside the textarea field. Upon form submission, I am replacing the HTML content using th ...

Can the combination of a double-quoted and single-quoted string be done securely?

Is there anything I need to be cautious about when attempting the following: $table_html = ' <td id="unescaped-double-quotes-yay">Some stuff</td>' . "\n"; I am not a fan of escaping double quotes in HTML and find single quotes ...

Adding color to text in typescript within an Angular 5 project: A tutorial

I've been attempting to show my data in a shade of green, but no matter what methods I try, the color is not showing up as expected. if(typeof(this._serverList)!="undefined"){ var apparr=this._ApplicationList.find(x=>x.appNm==app); let str ...

Curved in a dual manner

Currently, I am trying to create a unique 'wavy ghostly bottom' shape that features two double curves: While the lower portion of this illustration captures it more effectively. My Code My latest attempt at generating this shape involved using ...

Tips for displaying the UI Slider value on multiple fields simultaneously

I'm trying to display the value of a UI range slider in an input box. I have successfully done this, but now I want to show the same value in another div as well. Currently, I am able to capture the slider's value in the input box, but I also ne ...

Encountered an error while trying to click the cookie button using Selenium: "object[] does not have a size or

I've been struggling to interact with a button inside a pop-up using Selenium, but I keep encountering this error: object [HTMLDivElement] has no size and location I initially tried to simply click the button since it is visible on the page and I wai ...

How to dynamically add events to a JQuery FullCalendar using a loop

When utilizing the jQuery full calendar, I need to dynamically set events based on data obtained from a database. To achieve this, I am using data attributes to assign values and then display them on the calendar. Below is an example of my html twig code: ...

qbittorrent Application Encountering 'Element Not Found' Error During Selenium Automation Testing

My goal is to automate the process of downloading movies through magnet links using the BitTorrent web UI. I encounter an issue when trying to add the torrent link as my code fails to locate the element where it should be inserted. The same problem arises ...

The Controller in Angular.js is initialized after the view is loaded

I am facing an issue where I need to return the URL of each ID I receive, but the URL is being generated asynchronously. This delay in generation is causing a problem as I am unable to display it on the view immediately. How can I make the code wait unti ...

Guide to collapsing the hamburger style menu in React-Bootstrap when a link is clicked within it

In my development projects, I utilize the react-bootstrap library and am currently working on a website where all the content is contained on a single page. As a result, all of my links point to different scroll positions on the same page. However, I have ...

Applying a box shadow in Internet Explorer that creates a border-like effect of 1

After adding a box shadow to the mark tag for extra spacing on the right and left, I noticed that all browsers except Internet Explorer display it correctly. However, in IE, there is a 1px border-like effect visible. Is there a solution to fix this issue? ...

What is the best way to create a hover effect exclusively for the hamburger icon, and not for the close button

I am facing an issue with the code snippet below: .btn-menu:hover .btn-menu__bars::before{ transform: translateY(-0.5875rem); } .btn-menu:hover .btn-menu__bars::after{ transform: translateY(0.5875rem); } Is there a way to make this hover effect only a ...

Send the user back to the previous page once authentication is complete

I am integrating Google authentication through Passport in my web application and I am facing an issue with redirecting the user back to the original page they requested after a successful sign-in. It seems like the use of location.reload() might be causin ...

The hyperlink function is not operational in Gmail attachments

Using an anchor tag to navigate to a specific section within the same page works perfectly when the HTML file is on my local machine. However, when I attach the file in Gmail and open the attachment, it doesn't work. Why is this happening? How can I m ...

Troubleshooting: Angular.js error when Typescript class constructor returns undefined

I'm currently trying to create a simple TypeScript class, however I keep encountering an error stating this is undefined in the constructor. Class: class MyNewClass { items: string; constructor(){ this.items = 'items'; ...

Guide to creating draggable text on a video with HTML

I have a challenge where I need to overlay text on a video and make it draggable across the entire video. Currently, I am able to display the text over the video successfully, but when I try to drag it and then drop it, the text appears below the video and ...

Eslint requires that return values are used effectively

I am seeking a TypeScript or ESLint rule that enforces the usage of return values from functions. For example: const getNum = () => 12 This rule should allow me to call the function and store the returned value like this: const a = getNum() However, i ...