Get big files to MediaElement

3 posts, 0 answers
  1. Manuel
    Manuel avatar
    61 posts
    Member since:
    Oct 2011

    Posted 23 Feb 2012 Link to this post

    Hi there,

    I´m using MediaElement to display Audio. The size of this mp3 files is approx 50 MB, and this is a problem, because the application return an async exception.

    I get this mp3 files using a webService, that means, when the user clicks in play button, the application calls a webService, and get the mp3 file, however, as the file is too big, occurs an exception.

    Here is the code that calls the webservice:


    ~private void descarregaGravacao()
            {
                this.bsyIndicator.IsBusy = true;
                BtnAbre.Visibility = System.Windows.Visibility.Collapsed;
                BtnPausa.Visibility = System.Windows.Visibility.Visible;

                this.NomeFicheiroReproducao.Text = "A reproduzir gravação: " + DocumentoReuniaoSeleccionado.DesignacaoProp;

                BasicHttpBinding bind = new BasicHttpBinding();
                EndpointAddress endpoint = new EndpointAddress("../WebServ/webServiceSGA.asmx");
                bind.MaxBufferSize = 500000000;
                bind.MaxReceivedMessageSize = 500000000;

                servicoWebSGA.webServiceSGASoapClient client = new servicoWebSGA.webServiceSGASoapClient(bind, endpoint);


                if (UltimaPosicaoPlayer.IsZero())
                {
                    if (DocumentoReuniaoSeleccionado.UrlFicheiroProp != null && DocumentoReuniaoSeleccionado.VersaoDocumentoProp != null)
                    {
                        client.downloadDocumentoReuniaoCompleted += new EventHandler<servicoWebSGA.downloadDocumentoReuniaoCompletedEventArgs>(client_downloadDocumentoReuniaoCompleted);
                        client.downloadDocumentoReuniaoAsync(AppGlobais.Globais.reuniaoGlobal.IdProp.ToString(), DocumentoReuniaoSeleccionado.UrlFicheiroProp, (int)DocumentoReuniaoSeleccionado.VersaoDocumentoProp, AppGlobais.Globais.configuracaCaminhoDocumentos.CaminhoDocumentos);
                    }
                    else
                    { MessageBox.Show("Ocorreu um erro a descarregar o ficheiro de áudio."); }
                }
                else
                {
                    this.bsyIndicator.IsBusy = false;
                    MediaEl.Pause();
                    MediaEl.Position = UltimaPosicaoPlayer;
                    MediaEl.Play();
                }
            }

    And the callback:

     void client_downloadDocumentoReuniaoCompleted(object sender, servicoWebSGA.downloadDocumentoReuniaoCompletedEventArgs e)
            {
                BasicHttpBinding bind = new BasicHttpBinding();
                EndpointAddress endpoint = new EndpointAddress("../WebServ/webServiceSGA.asmx");
                bind.MaxBufferSize = 600000000;
                bind.MaxReceivedMessageSize = 600000000;

                if (e.Result != null)
                {
                    MessageBox.Show("Audio completo\n" + e.Result.Length.ToString());
                    try
                    {
                        Stream audio = new MemoryStream(e.Result);
                        MediaEl.SetSource(audio);
                        this.MediaEl.Play();
                        
                    }
                    catch (Exception ex)
                    { MessageBox.Show("Ocorreu um erro com o ficheiro de áudio."); }

                }
                else
                {
                    MessageBox.Show("Não foi possível fazer download do ficheiro de áudio.");
                }

                if (carregaLegenda == true)//Se existe legenda descarrega-a
                {
                    if (DocumentoReuniaoSeleccionado.UrlFicheiroProp != null)
                    {
                        string[] nomeLegenda = DocumentoReuniaoSeleccionado.UrlFicheiroProp.Split('.');

                        servicoWebSGA.webServiceSGASoapClient client = new servicoWebSGA.webServiceSGASoapClient(bind, endpoint);

                        client.DevolveLegendaCompleted += new EventHandler<servicoWebSGA.DevolveLegendaCompletedEventArgs>(client_DevolveLegendaCompleted);
                        client.DevolveLegendaAsync(nomeLegenda[0] + ".srt", AppGlobais.Globais.reuniaoGlobal.IdProp.ToString(), DocumentoReuniaoSeleccionado.VersaoDocumentoProp, AppGlobais.Globais.configuracaCaminhoDocumentos.CaminhoDocumentos);
                    }
                    else
                    {
                        MessageBox.Show("Escolha um ficheiro válido.");
                        this.bsyIndicator.IsBusy = false;
                    }

                    carregaLegenda = false;
                }

                this.bsyIndicator.IsBusy = false;
            }

    This is correct? Or there is some other way of do that?

    Thanks in advance,


  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 23 Feb 2012 Link to this post

    Hello Manuel,

    We are not aware of any limitations within the MediaElement with regard to the size of the mp3. I'd suggest you can try posting your question in the Silverlight forums as well, since there might be someone who has experienced the same problem.

    Kind regards,
    Kiril Stanoev
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Manuel
    Manuel avatar
    61 posts
    Member since:
    Oct 2011

    Posted 23 Feb 2012 Link to this post

    Hi,

    thanks for the fast reply.

    Ok, but my approach is correct? There is no problem download a file from server, and retrieve data in byte[] ?

    When I try this code in Visual Studio works good, but when I try download after deploy and doesn´t work, give exceptions..

    Because of that I supose that the problem maybe is because of size (50 mb), timeout..
Back to Top