本文整理汇总了C#中Android.Media.MediaPlayer.SetDisplay方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.SetDisplay方法的具体用法?C# MediaPlayer.SetDisplay怎么用?C# MediaPlayer.SetDisplay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Media.MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.SetDisplay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartVideoPlayback
public void StartVideoPlayback(SurfaceView surface, string FilePath)
{
if (_player != null)
{
StopVideoPlayback();
}
_player = new MediaPlayer();
ISurfaceHolder holder = surface.Holder;
holder.SetType(Android.Views.SurfaceType.PushBuffers);
holder.SetFixedSize(400, 300);
_player.SetDisplay(holder);
_player.SetDataSource(FilePath);
_player.Prepare();
_player.Start();
}
示例2: PlayVideo
private void PlayVideo(int Media)
{
DoCleanUp();
try
{
switch (Media)
{
case LOCAL_VIDEO:
//
// * TODO: Set the path variable to a local media file path.
//
path = "http://172.16.101.100:81/video/123.mp4";
if (path == "")
{
// Tell the user to provide a media file URL.
Toast.MakeText(this, "Please edit MediaPlayerDemo_Video Activity, " + "and set the path variable to your media file path." + " Your media file must be stored on sdcard.", ToastLength.Long).Show();
return;
}
break;
case STREAM_VIDEO:
//
// * TODO: Set path variable to progressive streamable mp4 or
// * 3gpp format URL. Http protocol should be used.
// * Mediaplayer can only play "progressive streamable
// * contents" which basically means: 1. the movie atom has to
// * precede all the media data atoms. 2. The clip has to be
// * reasonably interleaved.
// *
//
path = "http://172.16.101.100:81/video/123.mp4";
if (path == "")
{
// Tell the user to provide a media file URL.
Toast.MakeText(this, "Please edit MediaPlayerDemo_Video Activity," + " and set the path variable to your media file URL.", ToastLength.Long).Show();
return;
}
break;
}
// Create a new media player and set the listeners
mMediaPlayer = new MediaPlayer(this);
mMediaPlayer.SetDataSource(path);
mMediaPlayer.SetDisplay(holder);
mMediaPlayer.PrepareAsync();
mMediaPlayer.SetOnBufferingUpdateListener(this);
mMediaPlayer.SetOnCompletionListener(this);
mMediaPlayer.SetOnPreparedListener(this);
mMediaPlayer.SetOnVideoSizeChangedListener(this);
VolumeControlStream = Stream.Music;
}
catch (Exception e)
{
Log.Error(TAG, "error: " + e.Message, e);
}
}