I'm doing a music application. I'm trying to create a play method, this method return a string that contains the path that where the music are saved on project, example: mp3/music.mp3.

I need to take the string return of method and pass in source of how can I do this? I think that is using javascript, but I don't know about this language =/ anyone can help me here?

This is my view with the

    <div>
    <script src="Content/audiojs/audio.min.js"></script>

    <audio src=HERE I NEED TO PASS THE PATH FROM MUSIC preload="auto" />
<script>
    audiojs.events.ready(function () {
        var as = audiojs.createAll();

    });
</script>
</div>
<p>
    @Html.ActionLink("Create New", "Create")
</p>

<table>
    <tr>
        <th>
            <span>Genero</span>
        </th>

        <th>
            <span>Nome</span>
        </th>
        <th>
            <span>Artista</span>
        </th>
        <th>
            <span>Pre├žo</span>
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    if (item.UserId == Int32.Parse(Membership.GetUser().ProviderUserKey.ToString()))
    {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.genero.Nome)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Nome)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.NomeArtista)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Preco)
        </td>
        <td>
            @Html.ActionLink("Play", "Play", new { path = item.path }) |
            @Html.ActionLink("Edit", "Edit", new { id=item.MusicaId }) |
            @Html.ActionLink("Download", "Download", new { path = item.path }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.MusicaId })
        </td>
    </tr>
}
}

</table>

When I click on Play, the method will take the path saved on Music model and return a String, I need to take this String and pass in to play the music.

Play Method

 public String play(string path) 
{
  var arquivos = modelMusica.listaMusica();

  string nomeArquivo = (from m in arquivos where m.path == path select m.path).First();

  return nomeArquivo;

}

Thanks for all help provide :D

Related posts

Recent Viewed