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

MediaPlayer in ASP.NET Repeater

1 Answer 98 Views
MediaPlayer
This is a migrated thread and some comments may be shown as answers.
Juan Manuel
Top achievements
Rank 1
Juan Manuel asked on 17 Feb 2015, 03:37 AM
Hi I'm new here and I'm currently working with ASP.NET WebForms.

I had some issues trying to bind sources to a RadMediaPlayer that's inside a ASP Repeater:

<asp:Repeater ID="Publicaciones" runat="server" OnItemDataBound="FormatearPublicaciones" OnItemCommand="Publicaciones_ItemCommand">
    <ItemTemplate>
        <td><%# Eval("PublicacionId")%></td>
        <td><%# Eval("Mensaje")%></td>
        <td><asp:Image ID="PubImagen" runat="server" ClientIDMode="Static"/></td>
        <td>
            <telerik:RadMediaPlayer ID="PubAV" runat="server" ClientIDMode="Static" Width="350px" Height="250px"></telerik:RadMediaPlayer>
            <%--<audio id="PubAudio" runat="server" Width="350px" Height="250px"></audio>--%>
        </td>
        <br />
        <br />
    </ItemTemplate>
</asp:Repeater>


The repeater source is provided by a stored procedure which is called in code-behind and then I use the "OnItemDataBound" event of the repeater to format each ItemTemplate. I'm doing all this steps because I'm working on a social network and I want to manage different posts (images,videos,songs,etc).

Here is the code-behind of the repeater event:  

protected void FormatearPublicaciones(Object Sender, RepeaterItemEventArgs e)
{
    string filename = ((MuroEntity)e.Item.DataItem).PubMultimediaRuta;
    System.Web.UI.WebControls.Image imagenPub = e.Item.FindControl("PubImagen") as System.Web.UI.WebControls.Image;
    Telerik.Web.UI.RadMediaPlayer avPub = e.Item.FindControl("PubAV") as Telerik.Web.UI.RadMediaPlayer;
 
    if (((MuroEntity)e.Item.DataItem).Tipo.Equals("F"))
    {
        var imagenURL = Autenticado.Paths.Archivos + "thumb_" + filename;
        imagenPub.ImageUrl = imagenURL;
        avPub.Visible = false;
    }
    else if (((MuroEntity)e.Item.DataItem).Tipo.Equals("C") || ((MuroEntity)e.Item.DataItem).Tipo.Equals("V"))
    {
        avPub.Source = Autenticado.Paths.Archivos + filename;
        imagenPub.Visible = false;
    }
    else
    {
        avPub.Visible = false;
        imagenPub.Visible = false;
    }
}

The data bind of the repeater is working fine, for example the images binding is perfect but not the audio binding. You can see the player there but when you press play nothing happens, it seems like the source isn't there but i checked with the javascript console of google chrome and the source is there.

Here is also the static class that provides the path to the project local folder where the files (images,songs,videos,etc) are stored:

public static class Paths
{
    public static readonly string Archivos = "~/Archivos/" + SessionHelper.UsuarioAutenticado.Id.ToString() + "/"; // cannot change
    public static readonly string Archivos2 = "Archivos/" + SessionHelper.UsuarioAutenticado.Id.ToString() + "/";
    //public static int Total = 5; // can change because not const
}

I hope you can help me.

Thanks in advance.

John.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 20 Feb 2015, 07:13 AM
Hello John,

Please try to use the DataBinding event handler of the player and set a hardcoded video source using the (sender as RadMediaPlayer) approach. This will give a clue whether the player will work also with a dynamic source.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
MediaPlayer
Asked by
Juan Manuel
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or