本文整理汇总了C#中Android.Media.MediaPlayer.Start方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.Start方法的具体用法?C# MediaPlayer.Start怎么用?C# MediaPlayer.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Media.MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
ActionBar.Hide();
SetContentView(Resource.Layout.Main);
cover = FindViewById<RelativeLayout>(Resource.Id.titleScreen);
player = MediaPlayer.Create(this, Resource.Raw.avril_14th);
toggleMusic = FindViewById<ToggleButton>(Resource.Id.toggleMusic);
player.Start();
player.Looping = true;
cover.Click += delegate
{
StartActivity(typeof(Login));
};
toggleMusic.Click += (o, s) =>
{
if (toggleMusic.Checked)
{
player.Start();
toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPause);
}
else
{
toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPlay);
player.Pause();
}
};
}
示例2: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.Inflate(Resource.Layout.HomeScreen, container, false);
infoButton = view.FindViewById<Button>(Resource.Id.infoButton);
player = MediaPlayer.Create(view.Context, Resource.Raw.avril_14th);
toggleMusic = view.FindViewById<ToggleButton>(Resource.Id.toggleMusic);
cover = view.FindViewById<RelativeLayout>(Resource.Id.titleScreen);
Xamarin.Insights.Initialize(XamarinInsights.ApiKey, view.Context);
CurrentPlatform.Init();
player.Start();
player.Looping = true;
cover.Click += delegate
{
facebookLogin.Invoke(this, new LoginEventArgs());
};
toggleMusic.Click += (o, s) => {
if (toggleMusic.Checked)
{
player.Start();
toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPause);
}
else {
toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPlay);
player.Pause();
}
};
return view;
}
示例3: OnProgressChanged
public override void OnProgressChanged(WebView view, int newProgress)
{
base.OnProgressChanged(view, newProgress);
_context.SetProgress(newProgress * 100);
if (newProgress == 100)
{
_context.Title = view.Title;
bool soundEnabled = PreferenceManager.GetDefaultSharedPreferences(_context.ApplicationContext).GetBoolean("sounds", false);
if (soundEnabled)
{
_mediaPlayer = MediaPlayer.Create(_context.ApplicationContext, Resource.Raw.inception_horn);
_mediaPlayer.Completion += delegate { _mediaPlayer.Release(); };
_mediaPlayer.Start();
}
// add this page to the history
using (SQLiteDatabase db = _historyDataHelper.WritableDatabase)
{
var values = new ContentValues();
values.Put("Title", view.Title);
values.Put("Url", view.Url);
values.Put("Timestamp", DateTime.Now.Ticks);
db.Insert("history", null, values);
}
}
else
{
_context.Title = _context.ApplicationContext.Resources.GetString(Resource.String.title_loading);
}
}
示例4: OnElementChanged
protected override void OnElementChanged(ElementChangedEventArgs<Frame> e)
{
base.OnElementChanged(e);
if (Element == null)
return;
player = new MediaPlayer();
timer = new Timer(1000);
timer.Elapsed += timer_Elapsed;
player.Prepared += (sender, args) =>
{
try
{
player.SeekTo(0);
player.Start();
timer.Start();
}
catch
{
}
};
if (string.IsNullOrWhiteSpace(Player.Url))
return;
InitPlayer();
}
示例5: PlayWavFile
public bool PlayWavFile(string fileName)
{
_mediaPlayer = MediaPlayer.Create(global::Android.App.Application.Context, Resource.Raw.ding_persevy);
_mediaPlayer.Start();
return true;
}
示例6: PlaySoundAsync
public Task PlaySoundAsync(string filename)
{
// Create media player
var player = new MediaPlayer();
// Create task completion source to support async/await
var tcs = new TaskCompletionSource<bool> ();
// Open the resource
var fd = Xamarin.Forms.Forms.Context.Assets.OpenFd (filename);
// Hook up some events
player.Prepared += (s, e) => {
player.Start();
};
player.Completion += (sender, e) => {
tcs.SetResult(true);
};
// Initialize
player.SetDataSource (fd.FileDescriptor);
player.Prepare ();
return tcs.Task;
}
示例7: PlaySound
/// <summary>
/// Method that plays the sound on Android.
/// </summary>
public void PlaySound(SoundboardItem item)
{
player = new MediaPlayer ();
var fd = Xamarin.Forms.Forms.Context.Assets.OpenFd (item.FileName + ".mp3");
player.SetDataSource (fd.FileDescriptor);
player.Prepare ();
player.Start ();
}
示例8: OnCreate
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
// Create your application here
SetContentView(Resource.Layout.Menu);
mpButtonTap = MediaPlayer.Create (this, Resource.Raw.buttontap);
mimgSlogan = FindViewById<ImageView> (Resource.Id.limgMenuSlogan);
mimgSlogan.SetImageResource (Resource.Drawable.slogan);
mimgCoin = FindViewById<ImageView> (Resource.Id.limgCoinIcon);
mimgCoin.SetImageResource (Resource.Drawable.coin_small);
mbtnPlay = FindViewById<Button> (Resource.Id.lbtnPlay);
mbtnPhrases = FindViewById<Button> (Resource.Id.lbtnPhrases);
mbtnDictionary = FindViewById<Button> (Resource.Id.lbtnDictionary);
mbtnAchievements = FindViewById<Button> (Resource.Id.lbtnAchievements);
mtxtTip = FindViewById<TextView> (Resource.Id.ltxtTip);
mtxtCoin = FindViewById<TextView> (Resource.Id.ltxtCoin);
Database.createDatabase ("Tip");
Database.createDatabase("Coins");
Database.createDatabase ("Dictionary");
Database.createDatabase ("Phrases");
mtxtCoin.Text = Convert.ToString(Database.getCoins ());
mtxtTip.Text = Database.getRandomTip();
mbtnPlay.Click += (object sender, EventArgs e) => {
mpButtonTap.Start ();
StartActivity(typeof(actGame));
};
mbtnPhrases.Click += (object sender, EventArgs e) => {
mpButtonTap.Start ();
StartActivity(typeof(actPhrases));
};
mbtnDictionary.Click += (object sender, EventArgs e) => {
mpButtonTap.Start ();
StartActivity(typeof(actDictionary));
};
mbtnAchievements.Click += (object sender, EventArgs e) => {
mpButtonTap.Start ();
};
}
示例9: Play
public override void Play(string filename)
{
AssetFileDescriptor afd = Assets.OpenFd(filename);
player = new MediaPlayer();
player.SetDataSource(afd.FileDescriptor, afd.StartOffset, afd.Length);
player.Completion += DidFinishPlaying;
player.Prepare();
player.Start();
}
示例10: Play
public bool Play()
{
_player = MediaPlayer.Create(global::Android.App.Application.Context, Resource.Raw._01yes);
_player.Start();
_player.Completion += delegate
{
_player.Release();
};
return true;
}
示例11: Play
public void Play(string p_FilePath)
{
using (MediaPlayer player = new MediaPlayer()) {
if (p_FilePath.IndexOf ("Content") > -1) {
Android.Content.Res.AssetFileDescriptor af = Android.App.Application.Context.Assets.OpenFd (p_FilePath);
player.SetDataSource (af.FileDescriptor, af.StartOffset, af.Length);
} else {
player.SetDataSource (Path.Combine(DataPath,p_FilePath));
}
player.Prepare ();
player.Start ();
}
}
示例12: StartPlayer
public void StartPlayer(String filePath)
{
if (player == null) {
player = new MediaPlayer();
} else {
player.Reset();
player = MediaPlayer.Create(this, Resource.Raw.buffy);
// player.SetDataSource(filePath);
//player.Prepare();
player.Start();
}
}
示例13: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.Main);
_player = MediaPlayer.Create(this, Resource.Raw.test);
var playButton = FindViewById<Button> (Resource.Id.playButton);
playButton.Click += delegate {
_player.Start();
};
}
示例14: play
void play(string fullPath)
{
ISurfaceHolder holder = videoView.Holder;
holder.SetType (SurfaceType.PushBuffers);
holder.AddCallback( this );
player = new MediaPlayer ();
Android.Content.Res.AssetFileDescriptor afd = this.Assets.OpenFd(fullPath);
if (afd != null )
{
player.SetDataSource (afd.FileDescriptor, afd.StartOffset, afd.Length);
player.Prepare ();
player.Start ();
}
}
示例15: Play
public void Play(Context c)
{
if (mPlayer != null && !mPlayer.IsPlaying) {
mPlayer.Start();
return;
}
Stop();
mPlayer = MediaPlayer.Create(c, Resource.Raw.one_small_step);
mPlayer.Completion += (object sender, EventArgs e) => {
Stop();
};
mPlayer.Start();
}