Skip to content

MediaPlayer with LibVLCSharp: Volume control broken #21128

@lukasf

Description

@lukasf

Current behavior 🐛

When changing the volume using MediaPlayer.Volume property, no sound can be heard. Volume control is not possible. Volume range on the MediaPlayer.Volume property is defined as 0.0 to 1.0.

Expected behavior 🎯

Volume control should work as expected.

How to reproduce it (as minimally and precisely as possible) 🔬

Use MediaPlayer with LibVLC extension, e.g. on Desktop target.

Workaround 🛠️

Multiply volume with 100, so it is 0.0 to 100.0.

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

Desktop (Windows)

Uno.Sdk version (and other relevant versions) 📦

6.1.23

IDE version 🧑‍💻

Visual Studio 2022 17.14.2

Anything else we need to know? 💬

Volume in LibVLCSharp is defined like this:

    /// <summary>
    /// Get/Set the volume in percents (0 = mute, 100 = 0dB)
    /// </summary>
    public int Volume
    {
        get => Native.LibVLCAudioGetVolume(NativeReference);
        set => Native.LibVLCAudioSetVolume(NativeReference, value);
    }

Volume in MediaPlayer is defined like this:

//
// Summary:
//     Get or sets the audio volume for media playback.
//
// Returns:
//     The audio volume for media playback. The allowed range of values is 0 to 1. Values
//     outside of this range will be clamped.
public double Volume
{ ...

So the value from MediaPlayer.Volume value must be scaled with factor 100 to apply it to LibVLC and vice versa (in src/AddIns/Uno.UI.MediaPlayer.Skia.X11/SharedMediaPlayerExtension.cs). But currently it is just rounded, leading to the observed problems.

Metadata

Metadata

Assignees

Labels

difficulty/tbdCategorizes an issue for which the difficulty level needs to be defined.triage/untriagedIndicates an issue requires triaging or verification

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions