I'm trying to code an application that loops a video indefinitely in an xamarin application.
I'm using a Odroid-X4U as device to connect to a TV to make a "SaverScreen" that play videos.
Here my code :
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
session = new SessionManager(this);
memoryTextView = FindViewById<TextView>(Resource.Id.textViewMemory);
hourTextView = FindViewById<TextView>(Resource.Id.textViewHour);
memoryTimer = new Timer(UpdateMemory, null, 0, 1000);
videoView = FindViewById<VideoView>(Resource.Id.videoView1);
videoView.Completion += VideoView_Completion;
Window.AddFlags(WindowManagerFlags.Fullscreen);
PlayNextVideo();
}
private void PlayNextVideo()
{
string tmpPath = App.AppMainFolder + "/" + videoUrls[1];
videoView.SetVideoPath(tmpPath);
videoView.Start();
}
private void VideoView_Completion(object sender, EventArgs e)
{
videoView.StopPlayback();
videoView.Dispose();
videoView = FindViewById<VideoView>(Resource.Id.videoView1);
hourTextView.Text = DateTime.Now.ToString("HH:mm:ss");
currentIndex = (currentIndex + 1) % videoUrls.Length;
PlayNextVideo();
}
this code is functional, however after several hours the video freezes completely and I have to restart my device completely to restart the video.
I also put a little bloc of code to check the ram, and it's not a storage problem
private void UpdateMemory(object state)
{
var memoryInfo = new ActivityManager.MemoryInfo();
var activityManager = (ActivityManager)GetSystemService(ActivityService);
activityManager.GetMemoryInfo(memoryInfo);
RunOnUiThread(() =>
{
var currentTime = DateTime.Now.ToString("HH:mm:ss");
memoryTextView.Text = "RAM : " + (memoryInfo.AvailMem / 1048576L) + "MB | time : " + currentTime;
});
}
Does anyone have a solution so that the video doesn't freeze after a while?
I also went to the device logs (logcat) and nothing is displayed about the video bug.