Dear Friends,

I am developing such a website where i have uploaded the ringtones for mobile phones, and i need to know that how can i play the ringtone in the Asp .net C# page.

before download user can listen the ringtone and same action can done with Videos.

Please tell me the Idea with code snippet.

I HAVE DATALIST View Control for Ringtones and Videos.

Thanx in Advance :-)

Dani AI

Generated

Short answer for : bind your file URL into the DataList and render an HTML5 player for that item. A small server-side helper makes the ItemTemplate simple and keeps the markup readable. ’s suggestion to use a JS player is fine for UI polish, but you still need correct server binding, MIME types, and browser-friendly formats — this shows a minimal, production-friendly approach.

Example DataList item (use a Literal that calls a server helper):

<asp:DataList ID="dlMedia" runat="server">
  <ItemTemplate>
    <div class="mediaItem">
      <span><%# Eval("Title") %></span>
      <asp:Literal ID="litPlayer" runat="server" Text='<%# GetPlayerMarkup(Eval("FileUrl").ToString()) %>' />
    </div>
  </ItemTemplate>
</asp:DataList>

Example C# helper (code-behind):

protected string GetPlayerMarkup(string virtualPath)
{
    string ext = System.IO.Path.GetExtension(virtualPath).ToLowerInvariant();
    string url = ResolveUrl(virtualPath);
    if (ext == ".mp3")
        return string.Format("<audio controls preload='none'><source src='{0}' type='audio/mpeg' />Your browser does not support audio.</audio>", url);
    if (ext == ".mp4" || ext == ".webm" || ext == ".ogv")
        return string.Format("<video controls preload='none' width='320'><source src='{0}' type='{1}' />Your browser does not support video.</video>", url, GetMime(ext));
    return string.Format("<a href='{0}'>Download</a>", url);
}

Quick operational tips

  • Convert legacy 3gp/avi to MP4 (H.264/AAC) for consistent browser/mobile playback. Example ffmpeg commands:
    ffmpeg -i input.3gp -c:v libx264 -c:a aac -b:a 128k out.mp4
    ffmpeg -i input.avi -c:v libx264 -c:a aac -b:a 128k out.mp4
  • Ensure IIS serves correct MIME types (add/override in web.config under system.webServer/staticContent).
  • Use preload="none" to avoid loading every file; load on user action for bandwidth savings.
  • If you need seeking, serve files directly or implement Range-header support (206 Partial Content).
  • Troubleshoot with DevTools: test the direct file URL, confirm Content-Type, check permissions and console/network errors.

Caveat: many older phones expect 3gp, but modern browsers and devices work reliably with MP3 (audio) and MP4 (video). Converting to those formats and serving correct MIME types will solve most playback problems.

Recommended Answers

All 3 Replies

sorry it didn't helped me to solve the problem.

can u please post a little bit code to explain that how can i bind music files to the datalist items in my ASP .NET page (C#)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.