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

Song does not play in media player

5 Answers 87 Views
MediaPlayer
This is a migrated thread and some comments may be shown as answers.
G S S
Top achievements
Rank 1
G S S asked on 14 Sep 2009, 10:29 PM
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




5 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 17 Sep 2009, 08:04 AM
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.
0
G S S
Top achievements
Rank 1
answered on 19 Sep 2009, 01:39 AM
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)?
0
Kiril Stanoev
Telerik team
answered on 22 Sep 2009, 12:01 PM
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.
0
G S S
Top achievements
Rank 1
answered on 23 Sep 2009, 08:31 PM
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
0
Kiril Stanoev
Telerik team
answered on 24 Sep 2009, 02:33 PM
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.
Tags
MediaPlayer
Asked by
G S S
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
G S S
Top achievements
Rank 1
Share this question
or