Song does not play in media player

6 posts, 0 answers
  1. G S S
    G S S avatar
    85 posts
    Member since:
    Mar 2008

    Posted 14 Sep 2009 Link to this post

    I have a set of mp3s I want to play through the media player.

    They are defined through a collection, like so:

    System.Collections.Generic.List<SongTitlePath> SongTitlePaths = new List<SongTitlePath>();
                        
                SongTitlePaths.Add(new SongTitlePath("Song Title", "Path"));

    As you can see, the List is generic and is of type SongTitlePath, which takes the title and path parameters like so:

    public class SongTitlePath
        {
            
            public string Song, Path;
            
            public SongTitlePath(string song, string path )
            {
                
                this.Song = song;
                this.Path = path;
            
                
                // Insert code required on object creation below this point.
            }


    However, whenever I click play, the song does not play (no song can be heard) and of course the play head does not move.

    My paths are correct as I have pasted them into windows explorer to see their validity. My slashes are \ (backslash). Each song is on the local filesystem.

    Here is the code to add each collection entry to my media player:

        foreach (SongTitlePath s in SongTitlePaths)
                {    
                    var item = new Telerik.Windows.Controls.RadMediaItem();
                    item.Title = s.Song;
                    item.Source = new Uri(s.Path, UriKind.RelativeOrAbsolute);
                    this.radMediaPlayer.Items.Add(item);
                }
               

    What gives?

    Thanks




  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 17 Sep 2009 Link to this post

    Hello Gurdeep,

    Silverlight does not allow you to select files from the file system.
    This means that you cannot give a source that is out of the scope of the web project the Silverlight application is hosted in. What you can do in this case is to put your mp3 files in the ClientBin folder of your web project.
    Give it a try and let me know how it works for you.

    All the best,
    Kiril Stanoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. G S S
    G S S avatar
    85 posts
    Member since:
    Mar 2008

    Posted 18 Sep 2009 Link to this post

    Thanks, I will give this a go!

    On another note, how do I change the colour of the text in the playlist (in the main screen)?
  5. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 22 Sep 2009 Link to this post

    Hello Gurdeep,

    You can edit the control template of a media item and change the following brushes: TitleTextBlock and DescriptionTextBlock. These are the brushes to which the TextBlocks' Foreground properties are bound to. Next versions of RadMediaPlayer will provide a more straightforward way for achieving this.

    Kind regards,
    Kiril Stanoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. G S S
    G S S avatar
    85 posts
    Member since:
    Mar 2008

    Posted 23 Sep 2009 Link to this post

    Hi,

    How do I edit the ControlTemplate? Is this the same as:

    Edit Template > Edit Current ?

    This is just my slight lack of experience with Silverlight. The interface for editing these settings is not an issue with the control, but Expression Blend (I find the interface a little confusing but then I am new).

    Also, I did a find in the xaml markup. I found ControlTemplate in the markup but not the brushes elements to edit?

    EDIT: I just managed to edit the control template but still no sign of those brushes? I guess I need some sort of step by step walkthrough on this?

    Thanks
  7. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 24 Sep 2009 Link to this post

    Hello Gurdeep,

    I assume you were editting the ControlTemplate of RadMediaPlayer. In this case, you have to edit the ControlTemplate of RadMediaItem. This way you will be able to see the brushes. Bellow is a short walkthrough:

    1. If you are in Visual Studio, open the MainPage.xaml in Expression Blend.



    2. In Expression Blend, edit the ControlTemplate of any of the RadMediaItems.





    3.
    This is how the ControlTemplate of RadMediaItem looks like.



    4. From the right part of the screen, select the Resources tab. Somewhere in the bottom you should be able to see the brushes.



    5. Click the arrow on the right of the color box and edit the color of the brush according to your preferences. Changing the color will automatically reflect the media item.





    6. Go back to the page as show on the screen bellow.



    7. Finally, apply the edited template to the rest of your media items.



    Try this approach and let me know if you encounter any problems.


    Greetings,
    Kiril Stanoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
DevCraft banner