Xamarin.Android Videoview AddSubtitleSource

JessaJessa TRMember ✭✭

my code is this

private InputStream getSubtitleSource(string filepath)

{

InputStream ins = null;

string ccFileName = filepath.Substring(0, filepath.LastIndexOf('.')) + ".srt";

Java.IO.File file = new Java.IO.File(ccFileName);

if (file.Exists() == false)

{

return null;

}

FileInputStream fins = null;

try

{

fins = new FileInputStream(file);

}

catch (Exception e)

{

}

ins = (InputStream)fins;

return ins;

}

protected override void OnElementChanged(ElementChangedEventArgs e)

{

base.OnElementChanged(e);

if (e.OldElement != null || Element == null)

return;

videoView = new Android.Widget.VideoView(Forms.Context);

mediaController = new MediaController(Forms.Context);

mediaController.SetMediaPlayer(videoView);

videoView.SetMediaController(mediaController);

videoView.AddSubtitleSource(getSubtitleSource(Element.SubTitleUrl), MediaFormat.CreateSubtitleFormat("text/srt", "tr"));

SetNativeControl(videoView);

videoView.SetVideoURI(Android.Net.Uri.Parse(Element.Url));

progress = new ProgressDialog(Forms.Context, Resource.Style.progress_bar_style);

progress.Indeterminate = true;

progress.SetProgressStyle(ProgressDialogStyle.Spinner);

progress.SetCancelable(false);

progress.Show();

progress.SetContentView(new Android.Widget.ProgressBar(Forms.Context));

videoView.SetOnPreparedListener(this);

}

cannot convert from 'Java.IO.InputStream' to 'System.IO.Stream'
But I get this error in the following line
videoView.AddSubtitleSource(getSubtitleSource(Element.SubTitleUrl), MediaFormat.CreateSubtitleFormat("text/srt", "tr"));

Sign In or Register to comment.