本文整理汇总了C#中Windows.UI.Xaml.Controls.MediaElement类的典型用法代码示例。如果您正苦于以下问题:C# MediaElement类的具体用法?C# MediaElement怎么用?C# MediaElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaElement类属于Windows.UI.Xaml.Controls命名空间,在下文中一共展示了MediaElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MainPage
public MainPage()
{
this.DataContext = App.s_bike;
this.InitializeComponent();
_speech = new SpeechSynthesizer();
_audio = new MediaElement();
_audio.Volume = 1;
App.s_bike.iFitLED = C7ZL.OnOff.On;
App.s_bike.HeartRateChanged += m_bike_HeartRateChanged;
App.s_bike.RpmChanged += m_bike_RpmChanged;
App.s_bike.DifficultyChanged += m_bike_DifficultyChanged;
App.s_bike.ButtonDownPressed += S_bike_ButtonDownPressed;
App.s_bike.ButtonUpPressed += S_bike_ButtonUpPressed;
App.s_bike.ButtonEnterPressed += S_bike_ButtonEnterPressed;
App.s_bike.DialClickedClockwise += m_bike_DialClickedClockwise;
App.s_bike.DialClickedAnticlockwise += m_bike_DialClickedAnticlockwise;
tbDifficulty_value.Text = App.s_bike.Difficulty.ToString();
}
开发者ID:derektaprell,项目名称:PiBike2,代码行数:29,代码来源:MainPage.xaml.cs
示例2: ProactiveViewModel
/// <summary>
/// A view model class for the IndivReactive Scenario.
/// </summary>
public ProactiveViewModel(MediaElement mediaElement)
{
/// The ProtectionManager provides communication between the player and PlayReady DRM.
/// The helper class will configure the protection manager for PlayReady and assign an
/// event handler for Service requests.
this.ProtectionManager = PlayReadyHelpers.InitializeProtectionManager(ServiceRequested);
mediaElement.ProtectionManager = this.ProtectionManager;
/// The PlayReadyInfoViewModel is used in this sample app to show PlayReadyStatistics such as
/// SecurityLevel and hardware support within the UI.
PlayReadyInfo = new PlayReadyInfoViewModel();
PlayReadyInfo.RefreshStatics();
mediaElement.CurrentStateChanged += (s, a) => {
ViewModelBase.Log("Media State::" + mediaElement.CurrentState);
};
mediaElement.MediaFailed += (s, a) => {
ViewModelBase.Log("Media Failed::" + a.ErrorMessage);
};
/// Proactive license acqusition will ensure a license is available
/// prior to playback
CmdGetLicense = new RelayCommand(() => { GetLicense(new Guid(this.KeyId)); }, () => { return PlayReadyHelpers.IsIndividualized; });
/// Play is enabled once a license is available
CmdPlayMovie = new RelayCommand(() => { mediaElement.Source = new Uri(moviePath); SetPlaybackEnabled(true); },
() => IsLicenseAvailable(new Guid(KeyId)));
CmdStopMovie = new RelayCommand(() => { mediaElement.Stop(); SetPlaybackEnabled(false); },
() => IsLicenseAvailable(new Guid(KeyId)));
/// Proactive individualization will ensure PlayReady have been configured
/// to begin making license requests
IndividualizeIfNeeded();
}
开发者ID:huoxudong125,项目名称:Windows-universal-samples,代码行数:37,代码来源:ProactiveViewModel.cs
示例3: OnElementChanged
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Frame> e)
{
base.OnElementChanged(e);
if (Element == null)
return;
player = new MediaElement();
player.AutoPlay = true;
player.MediaOpened += (sender, args) =>
{
timer.Start();
};
this.Control.Child = player;
timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 1) };
timer.Tick += timer_Tick;
if (string.IsNullOrWhiteSpace(Player.Url))
return;
InitPlayer();
}
开发者ID:Adam--,项目名称:Hanselman.Forms,代码行数:25,代码来源:AudioPlayerRenderer.cs
示例4: InitializeComponent
public void InitializeComponent()
{
if (_contentLoaded)
return;
_contentLoaded = true;
Application.LoadComponent(this, new System.Uri("ms-appx:///Tweet.xaml"), Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application);
pageRoot = (Mu_genotype1.Common.LayoutAwarePage)this.FindName("pageRoot");
primaryColumn = (Windows.UI.Xaml.Controls.ColumnDefinition)this.FindName("primaryColumn");
progbar = (Windows.UI.Xaml.Controls.ProgressBar)this.FindName("progbar");
titlePanel = (Windows.UI.Xaml.Controls.Grid)this.FindName("titlePanel");
itemListScrollViewer = (Windows.UI.Xaml.Controls.ScrollViewer)this.FindName("itemListScrollViewer");
itemListScrollViewer2 = (Windows.UI.Xaml.Controls.ScrollViewer)this.FindName("itemListScrollViewer2");
PeerTweets = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("PeerTweets");
itemListView2 = (Windows.UI.Xaml.Controls.ListView)this.FindName("itemListView2");
mediaPlayer = (Windows.UI.Xaml.Controls.MediaElement)this.FindName("mediaPlayer");
TweetBox = (Windows.UI.Xaml.Controls.TextBox)this.FindName("TweetBox");
TweetIt = (Windows.UI.Xaml.Controls.Button)this.FindName("TweetIt");
PinPanel = (Windows.UI.Xaml.Controls.StackPanel)this.FindName("PinPanel");
itemListView = (Windows.UI.Xaml.Controls.ListView)this.FindName("itemListView");
PinTb = (Windows.UI.Xaml.Controls.TextBox)this.FindName("PinTb");
VerifyPinButton = (Windows.UI.Xaml.Controls.Button)this.FindName("VerifyPinButton");
backButton = (Windows.UI.Xaml.Controls.Button)this.FindName("backButton");
pageTitle = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("pageTitle");
pageSubtitle = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("pageSubtitle");
FullScreenLandscape = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenLandscape");
Filled = (Windows.UI.Xaml.VisualState)this.FindName("Filled");
FullScreenPortrait = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenPortrait");
FullScreenPortrait_Detail = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenPortrait_Detail");
Snapped = (Windows.UI.Xaml.VisualState)this.FindName("Snapped");
Snapped_Detail = (Windows.UI.Xaml.VisualState)this.FindName("Snapped_Detail");
TwitterConnectBtn = (Windows.UI.Xaml.Controls.Button)this.FindName("TwitterConnectBtn");
RefreshButton = (Windows.UI.Xaml.Controls.Button)this.FindName("RefreshButton");
}
开发者ID:sagar-sm,项目名称:Mu,代码行数:35,代码来源:Tweet.g.i.cs
示例5: Speaker
/// <summary>
/// have MediaElement defined in your XAML and pass it here
/// </summary>
/// <param name="_media"></param>
public Speaker(MediaElement _media)
{
media = _media;
media.MediaEnded += MediaElement_SpeakEnded;
synthesizer = new SpeechSynthesizer();
}
开发者ID:slgrobotics,项目名称:Win10Bot,代码行数:11,代码来源:Speaker.cs
示例6: StartMediaElement
private async void StartMediaElement()
{
// To use AudioCategory.BackgroundCapableMedia:
// * OnWindows 8 set MediaControl.PlayPressed, MediaControl.PausePressed,
// MediaControl.PlayPauseTogglePressed and MediaControl.StopPressed.
// * On Windows 8.1 set SystemMediaTransportControls.ButtonPressed.
systemControls = SystemMediaTransportControls.GetForCurrentView();
systemControls.ButtonPressed += OnButtonPressed;
systemControls.IsPlayEnabled = true;
systemControls.IsPauseEnabled = true;
systemControls.PlaybackStatus = MediaPlaybackStatus.Playing;
mediaPlayer = new MediaElement();
mediaPlayer.AudioCategory = AudioCategory.BackgroundCapableMedia;
mediaPlayer.AutoPlay = true;
mediaPlayer.CurrentStateChanged += OnCurrentStateChanged;
this.Content = mediaPlayer;
HttpClient client = new HttpClient();
// Add custom headers or credentials.
client.DefaultRequestHeaders.Add("Foo", "Bar");
//Uri uri = new Uri("http://localhost/song.mp3?slow=1000&?bufferlength=100000&lastModified=true");
Uri uri = new Uri("http://video.ch9.ms/ch9/70cc/83e17e76-8be8-441b-b469-87cf0e6a70cc/ASPNETwithScottHunter_high.mp4");
HttpRandomAccessStream stream = await HttpRandomAccessStream.CreateAsync(client, uri);
// If you need to use HttpClient, use MediaElement.SetSource() instead of MediaElement.Source.
mediaPlayer.SetSource(stream, stream.ContentType);
}
开发者ID:kiewic,项目名称:MediaElementWithHttpClient,代码行数:31,代码来源:MainPage.xaml.cs
示例7: Play
public async Task Play(Song a, MediaElement m)
{
if (Songs.Count != 0)
{
if (Songs.Contains(a))
{
NowIndex = Songs.IndexOf(a);
}
else
{
Songs.Add(a);
NowIndex = Songs.IndexOf(a);
}
}
else
{
Songs.Add(a);
NowIndex = 0;
}
await Task.Run(() =>
{
a.PlayOnce();
});
var stream = await a.AudioFile.OpenAsync(Windows.Storage.FileAccessMode.Read);
m.SetSource(stream, a.AudioFile.ContentType);
OnNotifyPlayBackEvent(a);
}
开发者ID:aurora-lzzp,项目名称:com.aurora.aumusic,代码行数:28,代码来源:PlayBack.cs
示例8: OnNavigatedTo
protected override async void OnNavigatedTo(NavigationEventArgs navArgs)
{
MakePinWebAPICall();
try
{
//Create a new object for the color sensor class
colorSensor = new TCS34725();
//Initialize the sensor
await colorSensor.Initialize();
//Create a new SpeechSynthesizer
synthesizer = new SpeechSynthesizer();
//Create a new MediaElement
audio = new MediaElement();
//Initialize the GPIO pin for the pushbutton
InitializeGpio();
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
}
}
开发者ID:RGroenewald,项目名称:adafruitsample,代码行数:25,代码来源:MainPage.xaml.cs
示例9: MediaElementOut
public MediaElementOut(MediaElement mediaElement)
{
this.mediaElement = mediaElement;
mediaElement.MediaFailed += mediaElement_MediaFailed;
mediaElement.MediaOpened += MediaElementOnMediaOpened;
mediaElement.CurrentStateChanged += MediaElementOnCurrentStateChanged;
}
开发者ID:KarimLUCCIN,项目名称:NAudioCustom,代码行数:7,代码来源:MediaElementOut.cs
示例10: MainPage
public MainPage()
{
this.InitializeComponent();
if (!CheckForInternetAccess())
{
string msg1 = "An Internet connection is required for this app and it appears that you are not connected." + Environment.NewLine + Environment.NewLine;
string msg2 = "Make sure that you have an active Internet connection and try again.";
UpdateStatus("You are not connected to the Internet", true);
new MessageDialog(msg1 + msg2, "No Internet").ShowAsync();
}
else
{
InitNotificationsAsync();
}
mediaplayer = new MediaElement();
// On Windows, the Send button must be made visible since the Command Bar is not always
// visible and we don't want to force the user to swipe up every time they want to chat.
#if WINDOWS_APP
btnWinSend.Visibility = Windows.UI.Xaml.Visibility.Visible;
TextInput.Height = btnWinSend.Height;
#endif
}
开发者ID:harshitc,项目名称:AzureChatrforWindows,代码行数:25,代码来源:MainPage.xaml.cs
示例11: NowPlayingPageViewModel
public NowPlayingPageViewModel()
{
App.Current.Suspending += Current_Suspending;
App.Current.Resuming += Current_Resuming;
SongHistory = new ObservableCollection<ShoutcastSongHistoryItem>();
mediaElement = ((App)App.Current).MediaElement;
PlayCommand = CommandManager.CreateCommand(() =>
{
if (mediaElement != null)
if (mediaElement.CurrentState != MediaElementState.Playing)
{
mediaElement.Play();
MediaControl.IsPlaying = true;
}
});
PauseCommand = CommandManager.CreateCommand(() =>
{
if (mediaElement != null)
if (mediaElement.CurrentState != MediaElementState.Paused)
{
mediaElement.Pause();
MediaControl.IsPlaying = false;
}
});
}
开发者ID:Amrykid,项目名称:Hanasu,代码行数:28,代码来源:NowPlayingPageViewModel.cs
示例12: Initialize
/// <summary>
/// Initialize VideoPlayer.
/// </summary>
private static void Initialize(VideoStretch stretch)
{
#if NETFX_CORE
if (_videoPopup == null)
{
_videoPopup = new Popup();
}
_videoPopup.VerticalOffset = 0;
_videoPopup.HorizontalOffset = 0;
if (_videoElement == null)
{
_videoElement = new MediaElement();
}
_videoPopup.Child = _videoElement;
_videoElement.MediaEnded += _videoElement_MediaEnded;
_videoElement.MediaOpened += _videoElement_MediaOpened;
_videoPopup.Height = Window.Current.Bounds.Height;
_videoPopup.Width = Window.Current.Bounds.Width;
_videoElement.Tapped += _videoElement_Tapped;
_videoElement.Stretch = (Stretch)stretch;
_videoElement.AutoPlay = false;
_videoElement.Height = _videoPopup.Height;
_videoElement.Width = _videoPopup.Width;
_videoPopup.IsOpen = true;
#endif
}
开发者ID:khaerul10056,项目名称:MarkerMetro.Unity.WinIntegration,代码行数:37,代码来源:VideoPlayer.cs
示例13: StartTextToSpeech
static public async Task StartTextToSpeech(string text)
{
if (!string.IsNullOrEmpty(text))
{
try
{
if (_speech != null)
{
StopTextToSpeech();
}
var voice = GetSpeechVoice();
if (voice != null)
{
_speech = new SpeechSynthesizer();
_speech.Voice = voice;
SpeechSynthesisStream speechStream = await _speech.SynthesizeTextToStreamAsync(Utility.DecodeHtml(text));
_soundPlayer = new MediaElement();
_soundPlayer.SetSource(speechStream, speechStream.ContentType);
_soundPlayer.Play();
}
}
catch (Exception ex)
{
AppLogs.WriteError("SpeechServices", ex);
}
}
}
开发者ID:JerelStarks,项目名称:Thiroshiga,代码行数:29,代码来源:SpeechServices.cs
示例14: ReactiveViewModel
/// <summary>
/// A view model class for the ReactiveRequest Scenario.
/// The ViewModel takes a UI MediaElement in the contructor to wire up commands and events to simplify the sample.
/// Decoupling the MediaElement from the ViewModel would require addtional MVVM infrastucture.
/// </summary>
public ReactiveViewModel(MediaElement mediaElement)
{
/// The ProtectionManager provides communication between the player and PlayReady DRM.
/// The helper class will configure the protection manager for PlayReady and assign an
/// event handler for Service requests.
this.ProtectionManager = PlayReadyHelpers.InitializeProtectionManager(ServiceRequested);
mediaElement.ProtectionManager = this.ProtectionManager;
/// The PlayReadyInfoViewModel is used in this sample app to show PlayReadyStatistics such as
/// SecurityLevel and hardware support in the UI.
PlayReadyInfo = new PlayReadyInfoViewModel();
PlayReadyInfo.RefreshStatics();
/// Reactive license acqusition will happen automatically when setting the source of
/// a MediaElement to protected content.
CmdPlayMovie = new RelayCommand( () => { mediaElement.Source = new Uri(moviePath); SetPlaybackEnabled(true); });
/// The licenseUrl in the sample is set to return a non-peristent license. When there is a
/// hard Stop() on the playback, a new license will be requested on Play().
CmdStopMovie = new RelayCommand(() => { mediaElement.Stop(); SetPlaybackEnabled(false); });
mediaElement.CurrentStateChanged += (s, a) => {
ViewModelBase.Log("Media State::" + mediaElement.CurrentState);
};
mediaElement.MediaFailed += (s, a) => {
ViewModelBase.Log("Err::" + a.ErrorMessage);
};
}
开发者ID:huoxudong125,项目名称:Windows-universal-samples,代码行数:33,代码来源:ReactiveViewModel.cs
示例15: GameViewModel
protected GameViewModel()
: base()
{
CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
MediaPlayer = new MediaElement();
});
lock (locker)
{
if (StopwatchFile == null || AlarmFile == null)
{
LoadFileTask = Task.Run(async () =>
{
StorageFolder folder = await (await Package.Current.InstalledLocation.GetFolderAsync("Assets")).GetFolderAsync("Sounds");
StopwatchFile = await folder.GetFileAsync("Stopwatch.wav");
AlarmFile = await folder.GetFileAsync("Alarm.wav");
CheerFile = await folder.GetFileAsync("Cheer.wav");
AwwFile = await folder.GetFileAsync("Aww.wav");
VictoryFile = await folder.GetFileAsync("Victory.wav");
(await StopwatchFile.OpenAsync(FileAccessMode.Read)).AsStream().CopyTo(StopwatchStream);
(await AlarmFile.OpenAsync(FileAccessMode.Read)).AsStream().CopyTo(AlarmStream);
(await CheerFile.OpenAsync(FileAccessMode.Read)).AsStream().CopyTo(CheerStream);
(await AwwFile.OpenAsync(FileAccessMode.Read)).AsStream().CopyTo(AwwStream);
(await VictoryFile.OpenAsync(FileAccessMode.Read)).AsStream().CopyTo(VictoryStream);
});
}
}
}
开发者ID:Speedydown,项目名称:Thirty_Seconds_WP,代码行数:31,代码来源:GameViewModel.cs
示例16: App
/// <summary>
/// Initializes the singleton Application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
synth = new SpeechSynthesizer();
media = new MediaElement();
}
开发者ID:mhnd89,项目名称:knowplay-final,代码行数:12,代码来源:App.xaml.cs
示例17: SetSourceAsync
public async Task SetSourceAsync(MediaElement mediaElement, StorageFile file)
{
if (file != null)
{
mediaElement.Stop();
mediaElement.SetPlaybackSource(MediaSource.CreateFromStorageFile(file));
}
}
开发者ID:AlexZayats,项目名称:N7.MediaPlayer,代码行数:8,代码来源:DefaultSourceProvider.cs
示例18: GetMediaElement
public async Task GetMediaElement()
{
var element = new MediaElement();
var elm = GetRandomElement();
var stream = await elm.OpenAsync(FileAccessMode.Read);
element.SetSource(stream, elm.ContentType);
await PlayElement(element);
}
开发者ID:jeppevammenkristensen,项目名称:PunchlineDetector,代码行数:8,代码来源:MainPageViewModel.cs
示例19: count94
public count94()
{
this.InitializeComponent();
this.navigationHelper = new NavigationHelper(this);
this.navigationHelper.LoadState += navigationHelper_LoadState;
this.navigationHelper.SaveState += navigationHelper_SaveState;
synth = new SpeechSynthesizer();
media = new MediaElement();
}
开发者ID:mhnd89,项目名称:knowplay-final,代码行数:9,代码来源:count94.xaml.cs
示例20: SetVideoPresenters
private void SetVideoPresenters()
{
var boolToVisConverter = new BooleanToVisibilityConverter();
#if WIN10
var peerSwapChainPanel = new WebRTCSwapChainPanel.WebRTCSwapChainPanel();
var peerHandleBinding = new Binding
{
Source = DataContext,
Path = new PropertyPath("RemoteSwapChainPanelHandle"),
Mode = BindingMode.OneWay
};
peerSwapChainPanel.SetBinding(
WebRTCSwapChainPanel.WebRTCSwapChainPanel.SwapChainPanelHandleProperty,
peerHandleBinding);
PeerVideoPresenter.Content = peerSwapChainPanel;
var selfSwapChainPanel = new WebRTCSwapChainPanel.WebRTCSwapChainPanel();
var selfHandleBinding = new Binding
{
Source = DataContext,
Path = new PropertyPath("LocalSwapChainPanelHandle"),
Mode = BindingMode.OneWay
};
selfSwapChainPanel.SetBinding(
WebRTCSwapChainPanel.WebRTCSwapChainPanel.SwapChainPanelHandleProperty,
selfHandleBinding);
var selfSizeBinding = new Binding
{
Source = DataContext,
Path = new PropertyPath("LocalNativeVideoSize"),
};
selfSwapChainPanel.SetBinding(
WebRTCSwapChainPanel.WebRTCSwapChainPanel.SizeProperty,
selfSizeBinding);
SelfVideoPresenter.Content = selfSwapChainPanel;
#endif
#if WIN81
_peerMediaElement = new MediaElement
{
RealTimePlayback = true
};
PeerVideoPresenter.Content = _peerMediaElement;
_selfMediaElement = new MediaElement
{
RealTimePlayback = true
};
SelfVideoPresenter.Content = _selfMediaElement;
#endif
}
开发者ID:hungdluit,项目名称:ChatterBox,代码行数:57,代码来源:CallView.xaml.cs
注:本文中的Windows.UI.Xaml.Controls.MediaElement类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论