WWBN / AVideo

Create Your Own Broadcast Network With AVideo Platform Open-Source. OAVP OVP
https://avideo.tube/AVideo_OpenSource
Other
1.89k stars 972 forks source link

Auto Ajax Refresh page when stream is over on Home page and Live stream pages #9303

Open JoshWho opened 1 month ago

JoshWho commented 1 month ago

Need a way for when the live stream is over for it to auto ajax reload the page to show it is over.

JoshWho commented 1 month ago

To auto-refresh your live stream when it finishes and redirect to a "done" page, you'll need to get your hands dirty with some JavaScript and AJAX magic. Here's a step-by-step guide to help you achieve this:

Step 1: Set up your live stream Make sure you have a working live stream set up using a streaming service like Wowza, Azure Media Services, or any other platform of your choice. This will provide you with a live stream URL.

Step 2: Create a "done" page Create a simple HTML page that will serve as your "done" page. This page will be displayed when the live stream ends. You can add a nice message, a call-to-action, or even a confetti animation to celebrate the end of the stream!

Step 3: Use JavaScript to detect the end of the stream In your live stream page, add a JavaScript function to detect when the stream ends. You can do this by checking the readyState property of the video element: javascript

const videoElement = document.getElementById('liveStream');

videoElement.addEventListener('ended', () => {
  // Stream has ended, redirect to the "done" page
  window.location.href = 'done.html';
});

Step 4: Use AJAX to refresh the page To auto-refresh the page when the stream ends, you can use AJAX to send a request to the server and reload the page. Here's an example using jQuery: javascript

$.ajax({
  url: 'liveStream.html',
  success: function() {
    window.location.reload();
  }
});

Step 5: Put it all together Combine the JavaScript functions from steps 3 and 4 to create a seamless live stream experience: javascript

const videoElement = document.getElementById('liveStream');

videoElement.addEventListener('ended', () => {
  // Stream has ended, redirect to the "done" page
  window.location.href = 'done.html';

  // Use AJAX to refresh the page
  $.ajax({
    url: 'liveStream.html',
    success: function() {
      window.location.reload();
    }
  });
});

Step 6: Test and refine Test your implementation to make sure everything works as expected. You may need to adjust the timing of the AJAX request or the redirect to the "done" page based on your specific use case.

Remember, this is just a basic example to get you started. You may need to add additional error handling, customize the "done" page, or integrate with a backend server to provide a more robust solution.

What you think @DanielnetoDotCom

DanielnetoDotCom commented 2 weeks ago

I have plans to make the raid feature like Twitch, but it will take time and it is not on my roadmap yet

JoshWho commented 1 week ago

Let us know when you can get to this, it is really important.

DanielnetoDotCom commented 1 week ago

sorry but not too soon