Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implemented HLS stream source as new plugin type. #84

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

sepi
Copy link

@sepi sepi commented Nov 30, 2024

Also implemented show_controls and autoplay attributes on the video element. These are particularly useful when showing a live stream.

Description

In order to be able to show an rtsp live stream, an HLS video source is implemented using HLS.js. The script is currently embedded using a CDN.

In order to stream rtsp to the web, you first need to make an .m3u8 playlist file available using for example ffmpeg. The URL of this file can be used as URL of the stream source.

Related resources

Checklist

  • I have opened this pull request against master
  • I have added or modified the tests when changing logic
  • I have followed the conventional commits guidelines to add meaningful information into the changelog
  • I have read the contribution guidelines and I have joined #workgroup-pr-review on
    Slack to find a “pr review buddy” who is going to review my pull request.

Also implemented show_controls and autoplay attributes on the
video element. These are particularly useful when showing a
live stream.
@sepi sepi force-pushed the hls-stream-source branch from 605e6ad to b83f60b Compare November 30, 2024 15:21
@sepi sepi changed the title Implemented HLS stream source as new plugin type. feat: Implemented HLS stream source as new plugin type. Nov 30, 2024
{% endif %}

{% addtoblock "js" %}
<script src="https://cdn.jsdelivr.net/npm/hls.js@1.5.17/dist/hls.min.js "></script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra space here after the hls.min.js.

"""
Renders the HTML <source> element inside of <video> for an HLS stream defined by a .m3u8 URL.
"""
hls_source_url = models.CharField(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hls_source_url = models.CharField(
hls_source_url = models.URLField(

Should this be a URLField? Can the max_length fall back to Django's default?

Copy link
Member

@fsbraun fsbraun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @sepi !

Thanks for the PR! Looks good to me. I've added two comments.

In addition, can you add to the README the support of HLS streams?

Finally, can you add tests for the new plugin and model?

hls.loadSource(hlsUrl);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
console.log('manifest loaded, found ' + data.levels.length + ' quality level',);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log('manifest loaded, found ' + data.levels.length + ' quality level',);

Is this left over from debugging?

{% endif %}

{% addtoblock "js" %}
<script src="https://cdn.jsdelivr.net/npm/hls.js@1.5.17/dist/hls.min.js "></script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could that source be configurable and default to the cdn? Alternatively, please add a comment to the README on how to overwrite this template.

@vinitkumar
Copy link
Member

@sepi Would be great if you can address these review comments so that we can work together quickly to get this merged.

@sepi
Copy link
Author

sepi commented Dec 19, 2024

I reacted to all of your comments except for the tests. I don't really see any functionality I could test correctly. Maybe I also don't believe in tests or am just lazy :P

Copy link
Member

@vinitkumar vinitkumar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. @fsbraun Please have a look once too.

@fsbraun
Copy link
Member

fsbraun commented Dec 23, 2024

@vinitkumar @sepi To me, it seems, there's just a few small things ti fix:

  • Ruff complains about unsorted imports
  • Migrations seem to be missing

@fsbraun
Copy link
Member

fsbraun commented Dec 24, 2024

@sepi I had a look, and the change of CharField to URLField would have created another migration. Also, I think we should add tests for the new model and plugin. Would you mind having a look at the test_models.py and test_pluings.py files and take them as a template?

I made some updates to fix the migrations, superfluous spaces in the template and the test setup. (For some reason, I cannot compile the python 3.9 requirements on my machine - that can be fixed separately.)

PS: The existing tests revealed that your change to the video player template added unnecessary spaces...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants