Skip to content

Conversation

lo92fr
Copy link
Contributor

@lo92fr lo92fr commented Apr 8, 2025

Add a new feature media to simplify handling of media in Openhab

Description

See this issue for description :
#4710

@lo92fr lo92fr requested a review from a team as a code owner April 8, 2025 16:38
@lo92fr lo92fr force-pushed the feature-media branch 2 times, most recently from 8084f4d to 2192a70 Compare April 10, 2025 05:54
@lo92fr
Copy link
Contributor Author

lo92fr commented Apr 12, 2025

Hello @ALL,

@florian-h05, @digitaldan, @lsiepel,

I would apreciate if someone with more experience in core that me can give comments on this first version.
Especially, about the PlayerItem modifications.

I finally decide to drop my new BrowerMediaItem implementation, and modify the existing PlayerItem.
I introduce a new MediaType accepted command on it.
The idea is that this MediaType command would be use to play / queue an album / track / artist to play on the PlayerItem.

The MediaType is a complex type compose of:

  • The type of command : PLAY/QUEUE (for now).
  • A parameter (that id the id/path of entry to play).

This command would be relay from core to addons, and addons would have to implement if to handle the play/queue request.
I've currently test this approach with spotify and upnp addons, and it seems to work (minor some obvious bugs to handle).

Laurent

@lsiepel
Copy link
Contributor

lsiepel commented May 16, 2025

Not sure if i can be of much help here. If i have more tim ei could look into it, but i think others have more knowledge about these parts.

JFTR please don't use force-push as this makes it harder to review / keep track of changes.

@lo92fr
Copy link
Contributor Author

lo92fr commented Jun 18, 2025

Hello,

Make some progress on this today.
Of course, it will be not ready for 5.0, perharps for 5.1.
I fix some issues on popup navigations in UI part make things a littles more stables.
Also start to see how I can add a media Renderer popup to select the output device directly from the oh-player-control.

Still a lot of work to be done on it.
I like to have something simple to use for end user, where you have only one way to implement this whatever device you have in your configurations.

Laurent.

@wborn wborn added the enhancement An enhancement or new feature of the Core label Jun 20, 2025
@kaikreuzer kaikreuzer marked this pull request as draft July 17, 2025 10:14
@wborn wborn requested a review from Copilot July 26, 2025 15:47
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new media feature to simplify handling of media in OpenHAB, addressing issue #4710. The implementation adds comprehensive media management capabilities including new state and command types, a media service architecture, and REST endpoints for media browsing.

Key changes include:

  • Addition of new media-related type classes (MediaCommandType, MediaStateType, MediaCommandEnumType) for enhanced player item functionality
  • Implementation of a complete media service framework with model classes for organizing media content hierarchically
  • Introduction of REST endpoints and HTTP servlet for media browsing and device management

Reviewed Changes

Copilot reviewed 42 out of 43 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
PlayerItem.java Extended to support new media command and state types
MediaCommandType.java New complex type for media commands with device/binding context
MediaStateType.java New complex type for media state with playback information
MediaCommandEnumType.java Enum defining available media commands (PLAY, PAUSE, etc.)
MediaService.java Core service interface for media registry and device management
MediaServlet.java HTTP servlet providing web interface for media browsing
MediaResource.java REST endpoints for media sources and sinks
Various model classes Hierarchical media content organization (sources, albums, tracks, etc.)

@@ -0,0 +1,7 @@
package org.openhab.core.media.model;
Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Missing copyright header and author documentation. All other files in the media bundle include proper copyright headers and Javadoc comments.

Copilot uses AI. Check for mistakes.

@@ -0,0 +1,67 @@
package org.openhab.core.media;
Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Missing copyright header. Additionally, this appears to be test/debug code that should not be included in production.

Copilot uses AI. Check for mistakes.

@@ -0,0 +1,21 @@
package org.openhab.core.io.rest.media.internal;
Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Missing copyright header and class documentation.

Copilot uses AI. Check for mistakes.

@@ -0,0 +1,21 @@
package org.openhab.core.io.rest.media.internal;
Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Missing copyright header and class documentation.

Copilot uses AI. Check for mistakes.

}

public String getPlayerItemName() {
return this.getPlayerItemName();
Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Recursive call to getPlayerItemName() will cause a StackOverflowError. Should return this.playerItemName instead.

Suggested change
return this.getPlayerItemName();
return this.playerItemName;

Copilot uses AI. Check for mistakes.

return artUri;
}

public String getExternalArtUri() {
Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Potential NullPointerException if getMediaRegistry() returns null. The method should include null checking before calling getMediaService().

Suggested change
public String getExternalArtUri() {
public String getExternalArtUri() {
if (this.getMediaRegistry() == null) {
throw new IllegalStateException("MediaRegistry is not available.");
}

Copilot uses AI. Check for mistakes.

<parent>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.reactor.bundles</artifactId>
<version>5.0.0-SNAPSHOT</version>
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
<version>5.0.0-SNAPSHOT</version>
<version>5.1.0-SNAPSHOT</version>

<parent>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.reactor.bundles</artifactId>
<version>5.0.0-SNAPSHOT</version>
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
<version>5.0.0-SNAPSHOT</version>
<version>5.1.0-SNAPSHOT</version>

lo92fr added 10 commits October 13, 2025 19:24
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
lo92fr added 21 commits October 13, 2025 19:34
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
…ng PlayerItem

Signed-off-by: Laurent ARNAL <laurent@clae.net>
…of command : PLAY, ENQUEUE

Signed-off-by: Laurent ARNAL <laurent@clae.net>
…evice directly from oh-player-controls

Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
…cenario like target device change (currently test with spotify binding)

Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
…est / implements on upnp Binding)

Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
…ify)

Signed-off-by: Laurent ARNAL <laurent@clae.net>
…ify)

Signed-off-by: Laurent ARNAL <laurent@clae.net>
- add mapping from MediaSink to item player name
- extends mediaType to handle more state directly from binding : currentTrack, currentArtist, currentTrackPosition/Duration / volume

Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An enhancement or new feature of the Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants