<commit_before>﻿using System;
using MediaManager.Media;
using MediaManager.Playback;
using MediaManager.Player;
using MediaManager.Queue;
using MediaManager.Video;
using Xamarin.Forms;

namespace MediaManager.Forms
{
    public class VideoView : View, IDisposable
    {
        protected static IMediaManager MediaManager => CrossMediaManager.Current;
        protected static IVideoView PlayerView => MediaManager.MediaPlayer.VideoView;

        public VideoView()
        {
            MediaManager.BufferedChanged += MediaManager_BufferedChanged;
            MediaManager.PositionChanged += MediaManager_PositionChanged;
            MediaManager.StateChanged += MediaManager_StateChanged;
            MediaManager.MediaItemChanged += MediaManager_MediaItemChanged;

            MediaManager.PropertyChanged += MediaManager_PropertyChanged;
        }

        private void MediaManager_MediaItemChanged(object sender, MediaItemEventArgs e)
        {
            if (Source != e.MediaItem)
                Source = e.MediaItem;
        }

        private void MediaManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
                //TODO: This seems not to be triggered
                case nameof(MediaManager.Duration):
                    Duration = MediaManager.Duration;
                    break;<commit_msg>Fix for string source in VideoView in Xamarin.Forms<commit_after>﻿using System;
using MediaManager.Media;
using MediaManager.Playback;
using MediaManager.Player;
using MediaManager.Queue;
using MediaManager.Video;
using Xamarin.Forms;

namespace MediaManager.Forms
{
    public class VideoView : View, IDisposable
    {
        protected static IMediaManager MediaManager => CrossMediaManager.Current;
        protected static IVideoView PlayerView => MediaManager.MediaPlayer.VideoView;

        public VideoView()
        {
            MediaManager.BufferedChanged += MediaManager_BufferedChanged;
            MediaManager.PositionChanged += MediaManager_PositionChanged;
            MediaManager.StateChanged += MediaManager_StateChanged;
            MediaManager.MediaItemChanged += MediaManager_MediaItemChanged;

            MediaManager.PropertyChanged += MediaManager_PropertyChanged;
        }

        private void MediaManager_MediaItemChanged(object sender, MediaItemEventArgs e)
        {
            if (Source is string url)
            {
                if (url != e.MediaItem.MediaUri)
                    Source = e.MediaItem.MediaUri;
            }
            else if (Source is IMediaItem)
            {
                if (Source != e.MediaItem)
                    Source = e.MediaItem;
            }
        }

        private void MediaManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
                //TODO: This seems not to be triggered
                case nameof(MediaManager.Duration):
                    Duration = MediaManager.Duration;
                    break;
{'fraction_non_alphanumeric': 0.06332369013179043, 'fraction_numerical': 0.0, 'mean_word_length': 2.324786324786325, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1983241', 'n_tokens_mistral': 731, 'n_tokens_neox': 709, 'n_words': 169}