I have a web page which contains a silverlight control that hosts a RadMediaPlayer.
Javascript on the web page can tell the RadMediaPlayer to start playing a particular file.
This is almost working, except it won't start playing automatically. The user still has to press the start button.
Why doesn't RadMediaPlayer.Play() start it?
Edit: The first time my function PlayMediaFile is called, it does not start by itself. The second time my function is called, it DOES start (even if the user had not pressed the start button the first time, and even if it's a different media file then the first time).
Here is the code:
Javascript on the web page can tell the RadMediaPlayer to start playing a particular file.
This is almost working, except it won't start playing automatically. The user still has to press the start button.
Why doesn't RadMediaPlayer.Play() start it?
Edit: The first time my function PlayMediaFile is called, it does not start by itself. The second time my function is called, it DOES start (even if the user had not pressed the start button the first time, and even if it's a different media file then the first time).
Here is the code:
[ScriptableMember(ScriptAlias=
"playMediaFile"
)]
public
void
PlayMediaFile(
long
entityId,
string
fileName)
{
try
{
_tbDebugOutput.Text =
string
.Format(
"PlayMediaFile({0}, {1}"
, entityId, fileName);
SetPlaylist(entityId, fileName);
this
._radMediaPlayer.Play();
// This should start it playing! But it doesn't.
}
catch
(Exception ex)
{
this
._tbDebugOutput.Text = ex.ToString();
}
}
public
void
SetPlaylist(
long
entityId,
string
fileName)
{
var path = GenerateMediaFilePath(entityId, fileName);
RadMediaItem mediaItem =
new
RadMediaItem();
mediaItem.Source =
new
Uri(path, UriKind.RelativeOrAbsolute);
this
._radMediaPlayer.Items.Clear();
this
._radMediaPlayer.Items.Add(mediaItem);
}