datee / HaxeVLC

A bit of VLC integration for Haxe / OpenFL ... C++ target - Windows only.. for now..

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VLC audio distortion

tsmithf opened this issue · 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?

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.

commented

Hey, nice catch! Make a PR?