I would like to change the source of a Media Element in Windows Phone 8.1.
What i have done:
xaml.cs file:
MediaPlayer.Source = new Uri("ms-appx:///Assets/song1.mp3", UriKind.RelativeOrAbsolute);
MediaPlayer.Play();
And my MainPage.xaml file:
<MediaElement x:Name="MediaPlayer" Source="Assets/song1.mp3" AutoPlay="False"/>
The ting is that i want to change the source and then play the new source file.
But when i press the button te execute the above code the song does not play, nothing happens. And i'm sure i have the right file path.
Related
I'm trying to insert ad in a Windows Phone 8 app using Visual Studio 2013 Ultimate.
I inserted this code in MainPage.xaml :
xmlns:UI="using:Microsoft.Advertising.WinRT.UI"
And my Grid tag:
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<UI:AdControl
ApplicationId="----------------------"
AdUnitId="------"
HorizontalAlignment="Left"
Height="500"
Margin="0,0,0,0"
VerticalAlignment="Top"
Width="200"/>
</Grid>
Why do I get this error?
AdControl not exist in namespace "using: Microsoft.Advertising.WinRT.UI"
Errore2 type 'UI: AdControl' not found. Check for missing a reference to an assembly and all assembly to which you refer have been compiled
Right click on Reference in your Solution Explorer window and select Add Reference.
WINDOWS RT (UNIVERSAL APPS)
Then move on Windows Phone 8.1 Tab and select 'Extensions'. You should find Microsoft Advertising SDK for Windows Phone 8.1 XAML. Select it and click ok, then rebuild (F6)
WINDOWS PHONE SILVERLIGHT
Move on Assemblies tab, then click on Extensions and add these 2 references:
Microsoft.Advertising.Mobile
Microsoft.Advertising.Mobile.UI
Then you have to add in the XAML page this namespace:
xmlns:adv="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI"
and finally add the advertising control to your page:
<adv:AdControl ApplicationId="YOUR_APPLICATION_ID" AdUnitId="YOUR_AD_UNIT_ID"
Width="480" Height="80"/>
If you're not able to find references, it's beacuse you didn't install the SDK on your computer. Go here, download the right version according to your needs and install it, then repeat the steps.
Let me know if it works!
I am using the official phonegap plugin
Basically I am creating a folder in my isolated Storage and putting in there my
uri file (the result is something like this: /CapturedImagesCache/WP_20150423_013.jpg and I can see the folder and the file with windows Power Tool)
While it works with the photo and I can set my tag this way:
var image = document.getElementById('img1');
console.log("imageData: " + path);
image.src = path;
The same does not work with the video, I am still getting the uri of the file and creating it in my isolated but after setting up my only a message "Invalid Source" is displayed.
Why does it happen?
Is there anyone who used it before on windows phone?
Here is the source code of the plugin github
it is an issue for windows phone 8.1. Seems the local video cannot be accessed within webbrowser control which is used by cordova for windows 8 and windows 8.1 silverlight app. Here the link on MSDN.
I think you're trying to set the src of an image instead of video.
If you try it with a video element, it should work.
js:
var video = document.getElementById('vid');
video.src = mediaFiles[0].fullPath;
video.play();
html
<video id="vid"></video>
OK. Questions.
I know there is no CameraCaptureUI in Windows phone 8.1, so I have to use MediaCapture class. That's fine but what about UI? Do I have to make and position button in my screen from scratch?(like flash button, front camera button etc)
About Nokia Imaging SDK. does it provide any UI? and can I use that API for taking picture instead of working directly with MediaCapture?. I tried to find out some information about initializing and taking picture using nokia imaging sdk, but I couldn't find.
Can you let me know any useful link for implementing MediaCapture in windows phone 8.1? There are lots of links but only for silverlight 8.0 not 8.1.
You can use FileOpenPicker and if you specify .png and .jpg in the list of file types, the picker will have a camera capture button that will open standard camera capture UI:
FileOpenPicker picker = new FileOpenPicker();
picker.FileTypeFilter.Add(".png");
picker.FileTypeFilter.Add(".jpg");
picker.ContinuationData["Data"] = "Something"; // Will be passed back to the app after the picker finishes
picker.PickSingleFileAndContinue();
If you still want to write your own UI, check this link: http://www.romasz.net/how-to-take-a-photo-in-windows-runtime/
I am making an html5 app for windows phone 8 and I have a link that is generated by JavaScript and passed into a frame. I would like to put an open in browser button on the application bar. With ios you can do this by adding the _system to the link is there an equivalent in WP? Is there any way to open the browser without using the launcher or is there a way to get the JavaScript variable into the launcher?
You can use Launchers to open and system application
Below is the sample code for the same:
WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.Uri = new Uri("http://msdn.microsoft.com", UriKind.Absolute);
webBrowserTask.Show();
MSDN Reference:
How to use the web browser task for Windows Phone
Windows Phone 8 :
I have an HTML design to bind in webbrowser control.
In that HTML I need to set the image() dynamically from my windows 8 phone application itself (Eg:MyApp/Images/Done.png).
How to set this Image in my HTML dynamically?
Could any one help me on that?
In terms of Zen, WP8 tried to align Uris as close as possible to Win8 Uris. So whenever you ask yourself "How do WP8 Uris work?" a good starting point would be Win8 and WP7 behaved. For example, you'll see lots of "ms-appx:///" and "ms-appdata:///" all around WP8.
Specfically, In order to access an app's Image resources from a WebBrowser just specify the local file path.For example, start a new WP8 project and in MainPage.xaml add:
<phone:WebBrowser Source="myPage.html" />
And create myPage.html and add:
<html>
<body>
<img src="Assets/AlignmentGrid.png"/>
</body>
</html>
This would render the correct image as part of the WebBrowser. See attached .