在Xamarin.Forms
中,我有一个ActivityIndicator
和一个label
,当视频加载时会弹出,我希望在视频完全加载时正确禁用它。
我的代码“this.IsBusy”中有一个绑定,可正确启用/禁用ActivityIndicator
。
我注意到在调试中,我在视频开始时收到此消息:
05-05 14:17:09.843 V/MediaPlayer-JNI(19723): isPlaying: 1
问题:如何使用此isPlaying
状态将我的“this.IsBusy”变为假?可能吗?或者我是否需要自定义渲染器来实现这一切。
以下是我的XAML:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:PreAppStructure"
xmlns:roxv="clr-namespace:Rox;assembly=Rox.Xamarin.Video.Portable"
x:Class="PreAppStructure.Page3"
Title="Welcome to page 3">
<ContentPage.Content>
<Grid>
<roxv:VideoView x:Name="VideoView" AutoPlay="True" LoopPlay="True" ShowController="True" Source="http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4" />
<StackLayout BackgroundColor="Black" HorizontalOptions="Center" VerticalOptions="Center" IsVisible="True">
<ActivityIndicator Color="White"
x:Name="loader"
IsRunning="{Binding IsBusy}"
VerticalOptions="Center" HorizontalOptions="Center" />
<Label x:Name ="loadingtext" Text="Loading...Please wait!" HorizontalOptions="Center" TextColor="White" IsVisible="{Binding IsBusy}"/>
</StackLayout>
</Grid>
</ContentPage.Content>
</ContentPage>
以下是我的C#课程:
...
using Rox;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace PreAppStructure
{
public partial class Page3 : ContentPage
{
public Page3()
{
InitializeComponent();
this.BindingContext = this;
this.IsBusy = true; // Activity Indicator is now successfully visible!
// When the app reaches the "isPlaying" state, I wish the Activity Indicator to not be visible (false)
} //On this line, the page loads, video buffers and then the video plays
}
}