本文整理汇总了C#中Android.Media.MediaPlayer.SetSurface方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.SetSurface方法的具体用法?C# MediaPlayer.SetSurface怎么用?C# MediaPlayer.SetSurface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Media.MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.SetSurface方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlayVideo
private void PlayVideo(SurfaceTexture surfaceTexture)
{
DoCleanUp();
try
{
path = "http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8";
if (path == "")
{
// Tell the user to provide a media file URL.
Toast.MakeText(this, "Please edit MediaPlayerDemo_setSurface Activity, " + "and set the path variable to your media file path." + " Your media file must be stored on sdcard.", ToastLength.Long).Show();
return;
}
// Create a new media player and set the listeners
mMediaPlayer = new MediaPlayer(this, true);
mMediaPlayer.SetDataSource(path);
if (surf == null)
{
surf = new Surface (surfaceTexture);
}
mMediaPlayer.SetSurface(surf);
mMediaPlayer.PrepareAsync();
mMediaPlayer.SetOnBufferingUpdateListener(this);
mMediaPlayer.SetOnCompletionListener(this);
mMediaPlayer.SetOnPreparedListener(this);
VolumeControlStream = Stream.Music;
}
catch (Exception e)
{
Log.Error(TAG, "error: " + e.Message, e);
}
}
示例2: OnSurfaceTextureAvailable
public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
{
nn_surface = new Surface (surface);
RelativeLayout.LayoutParams l;
DisplayMetrics metrics = new DisplayMetrics();
nn_activity.WindowManager.DefaultDisplay.GetMetrics(metrics);
l = new RelativeLayout.LayoutParams(metrics.HeightPixels, metrics.WidthPixels);
l.AddRule(LayoutRules.CenterInParent);
float scale = (metrics.HeightPixels * 1.0f) / (metrics.WidthPixels * 1.0f);
textureview.ScaleX = scale;
textureview.LayoutParameters=l;
try {
nn_mediaplayer= new MediaPlayer();
//String uriPath = "android.resource://"+nn_activity.PackageName+"/raw/Tap5050_About";
nn_mediaplayer.SetDataSource(nn_activity,global::Android.Net.Uri.Parse("android.resource://"+nn_activity.PackageName +"/"+ Resource.Raw.Tap5050_About));
nn_mediaplayer.SetSurface(nn_surface);
nn_mediaplayer.Prepare();
nn_mediaplayer.Prepared+= (object sender, EventArgs e) => {
(sender as MediaPlayer).Start ();
};
nn_mediaplayer.Completion+= (object sender, EventArgs e) => {
(sender as MediaPlayer).SeekTo (0);
(sender as MediaPlayer).Pause ();
};
}catch(Exception e){
Toast.MakeText (nn_activity,"Sorry,Can not play the video",ToastLength.Long).Show();
}
}