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

How do I modify the MediaPlayer play list?

5 Answers 136 Views
MediaPlayer
This is a migrated thread and some comments may be shown as answers.
Gary Davis
Top achievements
Rank 2
Gary Davis asked on 06 Aug 2009, 07:10 PM
Basically, I'd like to use the player to add an album of tracks to listen to which seems easy enough. However, I'd like to add a button to each track so when clicked, an ASP.Net event will fire for that track. I'd like to have the rest of the item be clickable to play the track as it does by default.

I have looked at this posting (and others):

   http://www.telerik.com/community/forums/silverlight/media-player/blend-3-cannot-create-control-template.aspx

and also the documentation about the RadMediaItem:

   http://www.telerik.com/help/silverlight/radmediaplayer-radmediaitem.html

But am not sure how to do this. I loaded the project from the 1st link above in Blend 3 but it's pretty complex without any knowledge on using Blend or even if I have to.

If you can give me some pointers, I'd appreciate it. In the meantime, I will do a bit of studying on Expression Blend.

Thanks,
Gary Davis

5 Answers, 1 is accepted

Sort by
0
Gary Davis
Top achievements
Rank 2
answered on 11 Aug 2009, 08:41 PM
Bump!

Still looking for some direction.

Thanks,
Gary
0
Accepted
Bobi
Telerik team
answered on 12 Aug 2009, 07:42 AM
Hello Gary Davis,

We apologize for the delay reply.
For more information about how to use Telerik Silverlight controls and Expression Blend please take a look at the following article:

http://www.telerik.com/help/silverlight/radcontrols-for-silverlight-expression-blend-support.html
http://www.telerik.com/help/silverlight/extend-and-modify-builtin-themes.html

Please find attached a sample project that shows you how to place buttons to each track.

You can define some custom template like for example :
<ControlTemplate TargetType="Button" x:Key="PlayButtonTemplate">
            <Grid>
                <ContentPresenter />
            </Grid>
        </ControlTemplate>
And after that you have to set it as a template to the button in MediaPlayerItem controltemplate:
             <Button x:Name="PlayButton" Height="30" HorizontalAlignment="Right"
                                Template="{StaticResource PlayButtonTemplate}"
                                VerticalAlignment="Center" Width="25">
                            <Path Fill="#FFFFFFFF" Stretch="Fill" Data="M0,0 L50,25 L50,25 L0,50 z" />
                        </Button>

I hope that this will help you.
 Please let us know if you have any other questions.

All the best,
Boryana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Gary Davis
Top achievements
Rank 2
answered on 12 Aug 2009, 06:57 PM
Thanks a lot, Boryana. This is very helpful, though I will probably have more questions as I work with it.

Like, what makes the Play button play? I don't see an event connected to that button.

Thanks,
Gary
0
Gary Davis
Top achievements
Rank 2
answered on 12 Aug 2009, 09:10 PM

Here's a question based on your example. How do I add items to the playlist in code-behind? For example:

  var item = new RadMediaItem();
  item.Source = new Uri(mediaSource, UriKind.RelativeOrAbsolute);
  item.Title = title;
  item.Description = description;
  radMediaPlayer1.Items.Add(item);

This works but does not use your template. The two rows added declaritively use your template and the third added with the above code does not. The declaritive code from your example is:

  <telerikMediaPlayer:RadMediaItem VideoStretch="Fill"
    Template="{StaticResource MediaItemTemplate}"
    Source="http://mschnlnine.vo.llnwd.net/d1/ch9/4/6/3/9/0/4/CSharp4DesignTeam_ch9.wmv"
    Title="C# 4.0: Meet the Design Team"
    Description="Anders Hejlsberg, Eric Lippert, Paul Vick..." />

I could not figure out how to specify the template in the code behind.

Thanks,
Gary

0
Bobi
Telerik team
answered on 14 Aug 2009, 08:47 AM
Hi Gary Davis,

Please find attached a sample project that shows how to dynamically add RadMediaItems to the RadMediaPlayer using the custom created template:

private void Button_Click(object sender, RoutedEventArgs e)
        {
            string mediaSource = @"http://msstudios.vo.llnwd.net/o21/mix08/08_WMVs/BCT06.wmv";
            ControlTemplate mediaItemCustomTemplate = this.Resources["MediaItemTemplate"] as ControlTemplate;
            var item = new RadMediaItem();
            item.Template = mediaItemCustomTemplate;
            item.Source = new Uri(mediaSource, UriKind.RelativeOrAbsolute);
            item.Title = "Test added Item";
            item.Description = "Decription of the item";
            radMediaPlayer1.Items.Add(item);
        }


As to the question about the play button "PlayButton" is a part of the build in RadMediaItem functionality.
This means that setting Template="{StaticResource PlayButtonTemplate}" only change the appearance of the button but not its functionality.

I hope that this will help you.

All the best,
Boryana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
MediaPlayer
Asked by
Gary Davis
Top achievements
Rank 2
Answers by
Gary Davis
Top achievements
Rank 2
Bobi
Telerik team
Share this question
or