krumelur / volumeslider Goto Github PK
View Code? Open in Web Editor NEWXamarin.Forms media volume control
License: MIT License
Xamarin.Forms media volume control
License: MIT License
I cannot seem to find a way to change the volume via code. Whatever volume I set in the code only takes effect when a user interacts with the volume slider.
<StackLayout>
<!-- Place new controls here -->
<Button Text="Siren!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"
Clicked="SirenBtnClicked">
</Button>
<vs:VolumeSlider x:Name="volumeSlider" Volume="0.5" WidthRequest="300" HorizontalOptions="Center"/>
</StackLayout>
private void SirenBtnClicked(object sender, EventArgs e)
{
if (!audioPlayer.IsPlaying) {
audioPlayer.Play();
volumeSlider.SetValue(VolumeSlider.VolumeProperty, 1);
}
else
{
audioPlayer.Stop();
}
}
Hi, I have got the following error "Cannot access a disposed object.Object name: 'VolumeSliderPlugin.Droid.VolumeSliderRenderer'."
Reproduce:
1.Access the page that have implemented VolumeSlider and tried to adjust the volume at this time it is working perfectly.
2.After that left the page and go back to adjust the volume now you will get an error.
Here is the full error stack :
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'VolumeSliderPlugin.Droid.VolumeSliderRenderer'.
at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <9ed4c1a7b8844cdcb5330cc881c1cd6a>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <9ed4c1a7b8844cdcb5330cc881c1cd6a>:0
at Android.Views.View.get_Context () [0x0000a] in <3921e1c40bf740cab0f47696b3ad1282>:0
at VolumeSliderPlugin.Droid.VolumeSliderRenderer.HandleDeviceVolumeChanged (System.Object sender, VolumeSliderPlugin.Droid.VolumeChangedEventArgs e) [0x0003a] in :0
at VolumeSliderPlugin.Droid.CustomMediaRouterCallback.OnRouteVolumeChanged (Android.Media.MediaRouter router, Android.Media.MediaRouter+RouteInfo info) [0x0002c] in :0
at Android.Media.MediaRouter+SimpleCallback.n_OnRouteVolumeChanged_Landroid_media_MediaRouter_Landroid_media_MediaRouter_RouteInfo_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_router, System.IntPtr native_info) [0x00019] in <3921e1c40bf740cab0f47696b3ad1282>:0
at at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.75(intptr,intptr,intptr,intptr)
How to solve this issue?
Thank you in advance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.