HaxeVLC icon indicating copy to clipboard operation
HaxeVLC copied to clipboard

VLC audio distortion

Open tsmithf opened this issue 7 years ago • 2 comments

We have an application that starts by playing a corporate video using a new instance of VlcBitmap, there is also a skip button which disposes of the video.

Within the application there is also a button to replay the intro video at any time.

However when the video plays again the audio is badly distorted.

I'm not sure if it's simply double playing the audio, or the levels are incorrectly set.

Any ideas?

tsmithf avatar Mar 21 '18 12:03 tsmithf

Looking into the audio issue further I implemented the getVolume() function in the VlcBitmap.hx file...

public function getVolume():Float
{
	#if (cpp && !mobile)
	if (libvlc!=null && initComplete)
		return libvlc.getVolume();
	else
		return 0;
	#else 
		return 0;
	#end
}

Then querying the volume of the media during progress I noticed it would start at volume 100, but when replaying again it would jump to 255, the maximum it should be is 100, hence the distortion.

Looking at the LibVLC.cpp file I noticed the setVolume function was setting it to 255, I changed the following...

void LibVLC::setVolume(float volume)
{
	if (volume>100)
		volume = 100.0;

	vol = volume;
	if (libVlcMediaPlayer!=NULL && libVlcMediaPlayer!=nullptr)
	{
		try
		{
			//libvlc_audio_set_volume(libVlcMediaPlayer, volume);
			libvlc_audio_set_volume(libVlcMediaPlayer, 100.0);
		}
		catch(int e)
		{
		}
	}
}

And no distortion and the volume correctly reporting as 100.

tsmithf avatar Mar 21 '18 13:03 tsmithf

Hey, nice catch! Make a PR?

datee avatar Mar 26 '18 09:03 datee