I was trying to implement the sample app of running a wav file as shown in the microsoft virtual academy tutorial for beginners. I tried implement same code and ran app but my app does not play sound of wav file. I am running the app on emulator. and following is the code i implemented in xaml file:
<MediaElement x:Name="Quack" HorizontalAlignment="Left" Height="128" Margin="314,218,0,0" Grid.Row="1" VerticalAlignment="Top" Width="100"
Source="/Assets/quack.wav"
AutoPlay="True" Balance="1" Volume="1"/>
following is code in xaml.cs file
private void buttonQuack_Click(object sender, RoutedEventArgs e)
{
textQuack.Text = "Hear the sound";
QuackMediaElement.Play();
}
I just wondered if is there any setting required in emulator in order to enable volume or something
Related
I have a hyperlink inside a Text block. I want it to open the link int he web browser, but when I Click it I get a popup saying
"Search an app in the store"
and my app crashes.....
my XAML code is:
<TextBlock HorizontalAlignment="Right" Height="49" Margin="0,0,10,0" TextWrapping="Wrap" Width="326" Foreground="Black" FontSize="16">
<TextBlock.Inlines>
<Hyperlink Click="Hyperlink_Click" NavigateUri="www.bing.com">
<Hyperlink.Foreground>
<ImageBrush Stretch="Fill" ImageSource="Assets/Proceed.png"/>
</Hyperlink.Foreground>Don't have a Selfcare Account ? Register here.</Hyperlink>
</TextBlock.Inlines>
<!--<Hyperlink xml:space="preserve" Foreground="#000" FontSize="16">Don't have a Mobitel Selfacre Account ? Register here. </Hyperlink>-->
</TextBlock>
my CS code is:
private async void Hyperlink_Click(Windows.UI.Xaml.Documents.Hyperlink sender, Windows.UI.Xaml.Documents.HyperlinkClickEventArgs args)
{
await Launcher.LaunchUriAsync(new Uri("www.google.com"));
}
Kindly help me fix it... Any kind of help is appreciated....
Change the uri from www.bing.com to http://www.bing.com. It needs the protocol to determine the application it uses to start the url with.
Check these links for more information:
Auto-launching apps using file and URI associations for Windows Phone 8
URI schemes for launching built-in apps for Windows Phone 8
Reserved file and URI associations for Windows Phone 8
I'm new in creating apps for Windows Phone. I've got problem with redirecting to another page. I've created blank page with HyperlinkButtonand in .cs file I wrote this:
private void but_elf_Click(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(Elfy));
}
In xaml:
<HyperlinkButton x:Name="but_elf" Content="Elfy"
HorizontalAlignment="Center" Margin="100,125,100,255" Grid.Row="1"
VerticalAlignment="Center" Width="200" Height="70" />
When I launch app and click on the button - nothing happens. There are no errors, no messages. I've tried to put NavigateUri in button's property but after pressing button (in launched app) the message has shown: "You need to install an app for this task. Would you like to search for one in the Store?" After pressing "Yes" the app says: "Sorry, no apps found".
How to figure out this problem? I'm creating app for Windows Phone 8.1 in .NET Framework 4.5. Thanks for any help.
You are missing a reference for the 'Click'-event handler. Please change your XAML to this:
<HyperlinkButton x:Name="but_elf" Content="Elfy"
HorizontalAlignment="Center" Margin="100,125,100,255" Grid.Row="1"
VerticalAlignment="Center" Width="200" Height="70" Click="but_elf_Click" />
Please see:
C# Documentation for Click on MSDN
C# Documentation for HyperlinkButton on MSDN
I am making a windows phone app, I want to run the video whenever the button is pressed. I am using mediaelement to run it, here is the code:
XAML:
<MediaElement x:Name="myMediaElement"
Margin="0,40,0,40"
Height="400"
Width="240" />
<Button x:Name="playVideoButton"
Height="80"
Width="200"
Content="Play Video"
Click="playVideoButton_Click"/>
C#:
private void playVideoButton_Click(object sender, RoutedEventArgs e)
{
myMediaElement.Source = new Uri("ms-appx:///Assets/Video.mp4", UriKind.RelativeOrAbsolute);
myMediaElement.Play();
}
this is the basic code that i am trying to run the video so if this one runs i'll add pause feature as well, but unfortunately its not running.
Please help and thanks in Advance!
Shahrukh
you can refer a Nokia Developer Sample about Video Playback with MediaElement in Windows Phone or you can Use Media Player launcher instead. here is a MSDN Documentation about it. How to use the Media Player launcher for Windows Phone 8
In a Windows Phone 8.1 universal app, I could use this Code for a Pub Center ad.
//code behind:
if(adControl.HasAd)
{
}
//xaml:
<UI:AdControl x:Name="adControl" AutoRefreshIntervalInSeconds="60" ApplicationId="" AdUnitId="" HorizontalAlignment="Left" Height="70" IsAutoRefreshEnabled="True" VerticalAlignment="Top" Width="400" Foreground="Black" Background="Black"/>
But this function isn't avaible for a Silverlight App. Does someone know a equivalent to "adControl.HasAd" in a Windows Phone 8.0 App?
I don't think there is an equivalent in WP8.0. What you can do though is have your own bool and set/unset it with the following two events:
adControl.AdRefreshed:
Raised when the AdControl receives a new ad.
and
adControl.ErrorOccured:
Raised when the AdControl receives a new ad.
If you just want to collapse the advert when no ad is shown you can also use:
adControl.IsAutoCollapseEnabled = true;
I am working on windows store app (using xaml/C#), my question is can I have two media-elements on a single page, one will always play some background music and second will play some other sound depending upon user actions?
I tried it but not working for me, only background music is getting played the other sound is not getting played.
I can't see problem. you can use 2 media elements on the same page. mediaControl1 plays always and mediaControl2 starts to play when user clicks on button.
<Button Width="150" Height="150" Style="{StaticResource ButtonAppStyle}" Click="MainPage_Loaded">
<MediaElement x:Name="mediaControl1" Height="400" Source="Assets/muzika.mp3" RealTimePlayback="True" IsLooping="True" />
<MediaElement x:Name="mediaControl2" Source="Assets/firework1.wav" IsMuted="True"/>
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
mediaControl2.IsMuted = false;
mediaControl2.Play();
}