SMFPlayer flickers when page loads

Jul 25, 2012 at 11:45 PM

Hi

I'm new to silverlight and was wondering if anyone can help with this problem.

I tried to change the background colour of the SMFPlayer from black to white, i have managed to get that to work, but the problem is when the mediaplayer 1st loads the background appears black then the mediaplayer disappears(flickers) for about a second before re-appearing with the white background.

How can I stop the flicker so that the mediaplayer loads with a white background.

My code is below.

Thanks

George

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.SilverlightMediaFramework.Core;
using Microsoft.SilverlightMediaFramework.Core.Media;

namespace Web.SilverlightVideo
    {
    public partial class MainPage : UserControl
        {
        public MainPage()
            {
            InitializeComponent();

            PlaylistItem item = new PlaylistItem();
            item.MediaSource = new Uri("http://video3.smoothhd.com.edgesuite.net/ondemand/Big%20Buck%20Bunny%20Adaptive.ism/Manifest");
            //item.MediaSource = new Uri("http://streams.smooth.vertigo.com/elephantsdream/Elephants_Dream_1024-h264-st-aac.ism/manifest");
            item.DeliveryMethod = Microsoft.SilverlightMediaFramework.Plugins.Primitives.DeliveryMethods.AdaptiveStreaming;

            MP.MouseEnter += new MouseEventHandler(HoverOver);
            MP.MouseLeave += new MouseEventHandler(HoverLeave);

            MP.Playlist.Add(item);


            // Dispatcher.BeginInvoke(delegate()
            //        {
            //SMFPlayer p = new SMFPlayer();
            MP.IsControlStripVisible = false;
            //p.IsControlStripVisible = false;
            //      });
            MP.Play();

            }

        private void HoverLeave(object sender, MouseEventArgs e)
            {
            MP.IsControlStripVisible = false;
            }

        private void HoverOver(object sender, MouseEventArgs e)
            {
            //Dispatcher.BeginInvoke(delegate()
           // {
                MP.IsControlStripVisible = true;
            //});
            }
        }
    }


using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.SilverlightMediaFramework.Core;

namespace Web.SilverlightVideo
    {
    public class SMFPlayerBackground : SMFPlayer
        {
        protected override void OnMediaPluginLoaded()
            {
            base.OnMediaPluginLoaded();
            Control mediaElement = this.MediaPresenterElement.Content as Control;
            mediaElement.Background = new SolidColorBrush(Colors.White);
            }
        }
    }

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:smf="http://schemas.microsoft.com/smf/2010/xaml/player"       
    xmlns:media="clr-namespace:Microsoft.SilverlightMediaFramework.Core.Media;assembly=Microsoft.SilverlightMediaFramework.Core" 
    xmlns:SmoothStreaming="clr-namespace:Microsoft.Web.Media.SmoothStreaming;assembly=Microsoft.Web.Media.SmoothStreaming" 
    x:Class="Web.SilverlightVideo.MainPage"
    mc:Ignorable="d"
    d:DesignHeight="200" d:DesignWidth="450"
    xmlns:local="clr-namespace:Web.SilverlightVideo"
    >

    <Grid x:Name="LayoutRoot" Background="White">
        <local:SMFPlayerBackground Name="MP" PlaylistVisibility="Disabled" />
        <!--<smf:SMFPlayer Name="MP" PlaylistVisibility="Disabled"/>-->
        </Grid>
    <!--IsControlStripVisible="False"-->
</UserControl>