This question is locked. New answers and comments are not allowed.
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,
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,