Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8436655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:14:23+00:00 2026-06-10T07:14:23+00:00

When someone clicks a button I would like it to play a specified video

  • 0

When someone clicks a button I would like it to play a specified video (on mobile devices). What happens is that when someone clicks the button, I do an AJAX call on the client side like this:

$(".play").click(function(){
    var camerahash = $(this).data('hash');
    var cameratype = $(this).data('type');
    function doAjax(){
        $.ajax({
            url: 'myfile.php',
            success: function(data) {
                if (data == 'Initializing...')
                {
                    setTimeout(doAjax, 2000);
                }
                else
                {
                    $('#quote p').html(data);

                }

            }
        });

    }
    doAjax();
});

This has this div to print messages to the user:

<div id="quote"><p> </p></div>

The server code (myfile.php):

        $r = new HttpRequest('http://localhost...', HttpRequest::METH_GET);
        $r->send();
        $code = $r->getResponseCode();

        switch($code) {
            case 200:
                echo "Starting Stream...    ";
                echo '<a href="http://blah.m3u8">Play Stream</a>';
                echo '<br>';
                break;
            case 450:
                echo "Oops! Camera not found...";
                echo '<br>';
                break;
            case 550:
                echo "Oops! An error occurred...";
                echo '<br>';
                break;
            case 250:
                echo "Initializing...";
                break;
            default:
                echo "Error 600";
                echo '<br>';
                break;  
        }

This works but after pressing the button you get: Starting stream... Play Stream where Play Stream is a link you have to click to play the video. What I want instead is to start the video as soon as the button is clicked (and the proper status code is verified on the server).

I tried according to this post which is very similar.

But I can’t get json to work so I can’t put the url with a redirection such as: window.location.href = data.redirect; where on the server side redirect would have the url. Any ideas what I can do instead?

I should note that this is Joomla so the server code is not myfile.php but actually a component url, but I believe that is irrelevant for this question. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:14:24+00:00Added an answer on June 10, 2026 at 7:14 am

    Actually this ends up being quite simple. This old post did point to the right direction.

    I have everything I need on the client side, so I just have to redirect using window.location:

    window.location = 'http://myurl.com/playlist.m3u8';
    

    Therefore this works perfectly:

    $(".play").click(function(){
    var camerahash = $(this).data('hash');
    var cameratype = $(this).data('type');
    function doAjax(){
        $.ajax({
            url: 'myfile.php',
            success: function(data) {
                if (data == 'Initializing...')
                {
                    setTimeout(doAjax, 2000);
                }
                else
                {
                    $('#quote p').html(data);
                    window.location = 'http://myurl.com/playlist.m3u8';
    
                }
    
            }
        });
    
    }
    doAjax();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to play a sound when someone click home button of iphone/ipad,
For example, when someone clicks on a button.
I'd like a link where if someone clicks a mailto link they are also
I decided that my client would be overwhelmed by a lot of bells and
Please can someone tell me the technique that would be used, for the following
I would like to hide the UISearchBar most of the time and only call
I would like to show a dialog and still be able to receive button
I have a page with multiple comment boxes. When someone clicks the submit button
I'm looking for a way to expand a view when someone clicks on a
so, the thing is : when someone clicks on a link to my website

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.