This is a migrated thread and some comments may be shown as answers.

Get Started Problems

5 Answers 117 Views
MediaPlayer
This is a migrated thread and some comments may be shown as answers.
Bader
Top achievements
Rank 1
Bader asked on 23 Nov 2010, 05:02 PM
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:
<UserControl x:Class="SimpleMediaPlayer.MainPage"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.MediaPlayer"
    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

5 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 26 Nov 2010, 03:57 PM
Hello Bader,

Your code looks well and works fine when I have added required DLLs (only removed <telerikQuickStart:QuickStart.ConfigurationPanel> from the xaml). You need to add references to Telerik.Windows.Controls, Telerik.Windows.Controls.MediaPlayer and SmoothStreaming. Please take a look at the following article about how you can obtain the SmoothStreaming dll : http://chris.59north.com/post/Playing-Smooth-Streaming-videos-in-Silverlight.aspx. Alternativelly you can install our controls and get the SmoothStreaming dll from the examples.

Hope this helps. Please let us know if you need more info.

Greetings,
Hristo
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Bader
Top achievements
Rank 1
answered on 28 Nov 2010, 04:27 PM
Hello,

Thank you very much for your help, But I still have a problems with your mediaplayer control.
I have two SmoothStreaming.dll files: Microsoft.Web.Media.SmoothStreaming.dll (v - 1.0.837.34) and SmoothStreaming.dll (v - 1.0.0.0). I made a reference for each one alone and for both together, and I still have a problem: The attributes IsStreamingSource and StreamAttached are not recognized. I dont Know why. 

Please, I need your explaination.
It is apprecited to guide me step by step in order to solve the problem.

Regards,
Bader
0
Tina Stancheva
Telerik team
answered on 02 Dec 2010, 08:57 AM
Hi Bader,

Please accept my apology for the delayed response.

I prepared a sample project illustrating how to play SmoothStreaming video. Can you please have a look at it and let us know if it works for you. Also, if it doesn't illustrate your scenario correctly, can you please modify it accordingly so that we can further investigate your issues.

Also, please keep in mind that currently, the RadMediaPlayer supports only smooth streaming media encoded with Encoder 3, although we are considering supporting Encoder 4. You can vote for this feature in our PITS thus increasing its priority.

All the best,
Tina Stancheva
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Bader
Top achievements
Rank 1
answered on 02 Dec 2010, 02:52 PM
Hello,

Thank you very much for your help, It solves the problem,
I still have some qustions about the control itself:
1) In the MainPage.xaml there is a link (http://video3.smoothhd.com.edgesuite.net/ondemand/Big Buck Bunny Adaptive.ism/Manifest), Can you give me an explanation of the content of this page?
2) I noticed that if I change the value of IsStreamingSource to "False" then I can play just one movie (wmv), So how can I play several movies (A playlist)? I think that my first question is related to this issue, I'm not sure. If it is true, how can I modify the above xml in order to play my own movies? 

Regards,
Bader

0
Tina Stancheva
Telerik team
answered on 07 Dec 2010, 07:32 PM
Hello Bader,

My sample project illustrated how to play a single video using SmoothStreaming. The Big Buck Bunny video is a sample video that is used to simply demonstrates the SmoothStreming advantages.

Still, if you don't want to play a Smooth Streaming video you can check the attached example. You can also have a look at this help article. I hope it helps.

Best wishes,
Tina Stancheva
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
MediaPlayer
Asked by
Bader
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Bader
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or