Hello,
I have a problem with using telerik silverlight controls, for example the media player control.
This is the first time I use telerik silverlight controls, so please guide me step by step.
My code is based on following telerik demo http://demos.telerik.com/silverlight/#MediaPlayer/SmoothStreaming (First Look)
My MainPage.xaml:
My MainPage.xaml.cs:
I the Design view I recieve the following error message:
In the above code the, IsStreamingSource and StreamAttached are not recognized.
In addition explain to me how can I implement the Full screen mode without reference to QuickStart.
Please, I need your help in order to solve the problems and to display my video using the telerik controls.
It is apprecited to send me the modified code.
Regards,
Bader
I have a problem with using telerik silverlight controls, for example the media player control.
This is the first time I use telerik silverlight controls, so please guide me step by step.
My code is based on following telerik demo http://demos.telerik.com/silverlight/#MediaPlayer/SmoothStreaming (First Look)
My MainPage.xaml:
<
UserControl
x:Class
=
"SimpleMediaPlayer.MainPage"
xmlns:telerik
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.MediaPlayer"
xmlns:d
=
"http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc
=
"http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable
=
"d"
d:DesignWidth
=
"640"
d:DesignHeight
=
"480"
>
<
Grid
x:Name
=
"LayoutRoot"
>
<
telerik:RadMediaPlayer
x:Name
=
"player"
VerticalContentAlignment
=
"Top"
HorizontalContentAlignment
=
"Center"
Header
=
"{Binding RelativeSource={RelativeSource Self}, Path=MediaElement}"
SelectedIndex
=
"0"
>
<
telerik:RadMediaPlayer.HeaderTemplate
>
<
DataTemplate
>
<
Border
CornerRadius
=
"3"
Background
=
"White"
Padding
=
"15 5"
Margin
=
"0 10 0 0"
>
<
StackPanel
>
<
StackPanel
Orientation
=
"Horizontal"
Margin
=
"4"
>
<
TextBlock
Text
=
"Bitrate: "
Foreground
=
"Black"
/>
<
TextBlock
Text
=
"{Binding ., StringFormat=n0}"
Foreground
=
"Black"
/>
</
StackPanel
>
</
StackPanel
>
</
Border
>
</
DataTemplate
>
</
telerik:RadMediaPlayer.HeaderTemplate
>
<
telerik:RadMediaItem
IsStreamingSource
=
"True"
Header
=
"Big Buck Bunny"
Source
=
"http://video3.smoothhd.com.edgesuite.net/ondemand/Big Buck Bunny Adaptive.ism/Manifest"
StreamAttached
=
"RadMediaItem_StreamAttached"
>
<
telerik:RadMediaChapter
Content
=
"Chapter 1"
Position
=
"00:00:50"
/>
<
telerik:RadMediaChapter
Content
=
"Chapter 2"
Position
=
"00:03:00"
/>
</
telerik:RadMediaItem
>
</
telerik:RadMediaPlayer
>
</
Grid
>
<telerikQuickStart:QuickStart.ConfigurationPanel>
<StackPanel Margin="3">
<Button x:Name="FullScreenButton" Height="22" Click="FullScreenButton_Click"
Content="Toggle Full Screen" Margin="0,4,0,0" />
<Button x:Name="PlayListButton" Height="22" Click="PlayListButton_Click"
Content="Toggle Play List" Margin="0,4,0,0" />
</StackPanel>
</telerikQuickStart:QuickStart.ConfigurationPanel>
</
UserControl
>
My MainPage.xaml.cs:
using System;
using System.Collections.Generic;
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.Expression.Encoder.AdaptiveStreaming;
using Telerik.Windows.Controls;
namespace SimpleMediaPlayer
{
public partial class MainPage : System.Windows.Controls.UserControl
{
public MainPage()
{
InitializeComponent();
}
private void RadMediaItem_StreamAttached(object sender, EventArgs e)
{
RadMediaItem item = sender as RadMediaItem;
if (item != null)
{
AdaptiveStreamingSource adaptiveSource = new AdaptiveStreamingSource();
adaptiveSource.MediaElement = this.player.MediaElement;
adaptiveSource.ManifestUrl = item.Source;
adaptiveSource.PlayBitrateChange += adaptiveSource_PlayBitrateChange;
adaptiveSource.StartPlayback();
}
}
void adaptiveSource_PlayBitrateChange(object sender, BitrateChangedEventArgs e)
{
this.player.Header = e.Bitrate;
}
private void FullScreenButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
this.player.IsFullScreen = !this.player.IsFullScreen;
}
private void PlayListButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
this.player.IsPlaylistVisible = !this.player.IsPlaylistVisible;
}
}
}
I the Design view I recieve the following error message:
System.Reflection.TargetInvocationException
Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
System.InvalidOperationException
An unhandled exception was encountered while trying to render the current silverlight project on the design surface. To diagnose this failure, please try to run the project in a regular browser using the silverlight developer runtime.
at Microsoft.Windows.Design.Platform.SilverlightViewProducer.OnUnhandledException(Object sender, ViewUnhandledExceptionEventArgs e)
at Microsoft.Windows.Design.Platform.SilverlightViewProducer.SilverlightContentHost.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Designer.ZoomableViewPresenter.DesignerBackground.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
at Microsoft.Windows.Design.Interaction.DesignerView.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Designer.Viewport.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Interop.HwndSource.SetLayoutSize()
at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
at MS.Internal.DeferredHwndSource.ProcessQueue(Object sender, EventArgs e)
System.InvalidOperationException
[FrameworkElement_LayoutMeasure_InfinityNaNReturned]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.50917.0&File=System.Windows.dll&Key=FrameworkElement_LayoutMeasure_InfinityNaNReturned
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
In the above code the, IsStreamingSource and StreamAttached are not recognized.
In addition explain to me how can I implement the Full screen mode without reference to QuickStart.
Please, I need your help in order to solve the problems and to display my video using the telerik controls.
It is apprecited to send me the modified code.
Regards,
Bader