Microsoft Media Player Platform with AVC encoded MP4 on Win8 - windows-8

I have an AVC encoded MP4 file that I would like to play in the app. But it always failed to play and the error message is "MF_MEDIA_ENGINE_ERR_SRC_NOT_SUPPORTED : HRESULT - 0xC00D36B4". How should I resolve the problem?
BTW, the url is here:
http://coursecast2.nus.edu.sg/Panopto/Content/Sessions/1290e053-9cd0-4cda-812a-01a8bcd9a13d/91d06ea8-aaf8-463b-b8f3-1771109ff56e-e746270b-0142-413e-8587-48080a4c1c16.mp4
Thanks
EDIT 1:
I am using C# with XAML.
XAML:
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<mmppf:MediaPlayer x:Name="test" MediaFailed="failed"/>
</Grid>
C#:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
this.test.Source = new Uri("http://coursecast2.nus.edu.sg/Panopto/Content/Sessions/1290e053-9cd0-4cda-812a-01a8bcd9a13d/91d06ea8-aaf8-463b-b8f3-1771109ff56e-e746270b-0142-413e-8587-48080a4c1c16.mp4");
}
private void failed(object sender, ExceptionRoutedEventArgs e)
{
String fail = e.ToString();
}
Edit 2:

Related

how to convert WebView into IRandomAccessStream in UWP?

What i have Tried is?
My Xaml code :
<Grid x:Name="MyGrid">
<Button x:Name="but" Content="Click" Click="but_Click"></Button>
</Grid>
My C# code:
private async void but_Click(object sender, RoutedEventArgs e)
{
WebView x = new WebView();
x.Width = 100; x.Height = 100;
InMemoryRandomAccessStream ms = new InMemoryRandomAccessStream();
await x.CapturePreviewToStreamAsync(ms);
}
when I try to convert Webview to Stream.It throws an error like this.
I don't why this was happening .Can Anyone suggest me , How to convert webview to IRandomAccessstream?
The problem is the WebView has not rendered into xaml visual tree. we need to insert WebView into Page content before calling CapturePreviewToStreamAsync method.
private WebView x;
public MainPage()
{
this.InitializeComponent();
x = new WebView();
x.Height = 100; x.Width = 100;
RootGrid.Children.Add(x);
}
private async void bookmarkBtn_Click(object sender, RoutedEventArgs e)
{
InMemoryRandomAccessStream ms = new InMemoryRandomAccessStream();
await x.CapturePreviewToStreamAsync(ms);
}

How to block popups in cefsharp browser in vb.net project/ NOT c sharp

i have been looking for a while now, i have found a solution in csharp , but i couldn't translate it (implement it in my vb.net app).
My only aim is that when the user clicks a link no popups appear.
thank you for your help.
My vb.net coding skill is beginner level, c sharp no knowledge.
the working solution in c sharp:
using CefSharp;
using CefSharp.WinForms;
namespace popup_cefsharp
{
public partial class frm_main : Form
{
public frm_main()
{
InitializeComponent();
}
//variable
ChromiumWebBrowser chrome, chrome_popup;
private void initialize_browser()
{
try
{
CefSettings settings = new CefSettings();
Cef.Initialize(settings);
//main browser
chrome = new ChromiumWebBrowser(this.txt_url.Text.Trim());
LifespanHandler life = new LifespanHandler();
chrome.LifeSpanHandler = life;
life.popup_request += life_popup_request;
this.pan_container.Controls.Add(chrome);
chrome.Dock = DockStyle.Fill;
//second browser (popup browser)
chrome_popup = new ChromiumWebBrowser("");
this.pan_container_popup.Controls.Add(chrome_popup);
chrome_popup.Dock = DockStyle.Fill;
}
catch (Exception ex)
{
MessageBox.Show("Error in initializing the browser. Error: " + ex.Message);
}
}
private void carregar_popup_new_browser(string url)
{
//open pop up in second browser
chrome_popup.Load(url);
}
private void frm_main_FormClosing(object sender, FormClosingEventArgs e)
{
//close o object cef
Cef.Shutdown();
Application.Exit();
}
private void frm_main_Load(object sender, EventArgs e)
{
//initialize the browser
this.initialize_browser();
}
private void life_popup_request(string obj)
{
//function for open pop up in a new browser
this.carregar_popup_new_browser(obj);
}
}
}
link original post: https://www.codeproject.com/Articles/1194609/Capturing-a-pop-up-window-using-LifeSpanHandler-an
finally found the solution , if anyone is interested
here is the link, you will need to install the cefsharp nuggets packages, add lifespanhandler as a new class, the file is in the link, then copy the method to call the function from the mainform...
cheers...
https://github.com/messi06/vb.net_CefSharp_popup

Issues when saving files to OneDrive on Windows 10 Mobile

I’m working on an application where you should be able to open and save files, similar to “Notepad”. It’s a universal application that should work both on computers and mobiles.
The application works fine on computers. It also works fine on mobile if I save or open files locally or on Dropbox.
But if I open a file on OneDrive (via the file picker), and then try to save an exception is thrown: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
If I select “Save as” on OneDrive it works. But every time I select Save after this a new instance of the file is created (I get “file 1”, “file 2”, “file 3” and so on).
I have only tested this on my phone. I might have a bug on my application, but since it works on DropBox I don’t think so. Is this a known issue with OneDrive? Or might I just have some local issues? I’m using Windows 10 Mobile 10.10586.420 and OneDrive 17.11.
Here is some code to illustrate the problem:
<Page
x:Class="BasicEditor.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:BasicEditor"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="40">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Button Content="Open"
Click="OpenButton_Click" />
<Button Content="Save"
Click="SaveButton_Click" />
<Button Content="Save as"
Click="SaveAsButton_Click" />
</StackPanel>
<TextBox Grid.Row="1" x:Name="TextEditor"
TextWrapping="Wrap" />
</Grid>
</Page>
using System;
using System.Collections.Generic;
using Windows.Storage;
using Windows.Storage.AccessCache;
using Windows.Storage.Pickers;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
namespace BasicEditor
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
string MruToken;
private async void OpenButton_Click(object sender, RoutedEventArgs e)
{
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.List;
openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
openPicker.FileTypeFilter.Add(".txt");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
try
{
string fileContent = await FileIO.ReadTextAsync(file);
TextEditor.Text = fileContent;
string token = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList.Add(file, "");
MruToken = token;
}
catch (Exception ex)
{
System.Diagnostics.Debug.Write($"Open-Error: {ex.Message}");
var dialog = new MessageDialog($"Open-Error: {ex.Message}");
await dialog.ShowAsync();
}
}
}
private async void SaveButton_Click(object sender, RoutedEventArgs e)
{
try
{
var file = await StorageApplicationPermissions.MostRecentlyUsedList.GetFileAsync(MruToken);
string fileContent = await FileIO.ReadTextAsync(file);
await FileIO.WriteTextAsync(file, TextEditor.Text);
var dialog = new MessageDialog($"Saved successfully");
await dialog.ShowAsync();
}
catch (Exception ex)
{
System.Diagnostics.Debug.Write($"Save-Error: {ex.Message}");
var dialog = new MessageDialog($"Save-Error: {ex.Message}");
await dialog.ShowAsync();
}
}
private async void SaveAsButton_Click(object sender, RoutedEventArgs e)
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
savePicker.FileTypeChoices.Add("Plain Text", new List<string>() { ".txt" });
savePicker.SuggestedFileName = "New Document";
StorageFile file = await savePicker.PickSaveFileAsync();
if (file != null)
{
try
{
await FileIO.WriteTextAsync(file, TextEditor.Text);
string token = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList.Add(file, "");
MruToken = token;
}
catch (Exception ex)
{
System.Diagnostics.Debug.Write($"SaveAs-Error: {ex.Message}");
var dialog = new MessageDialog($"SaveAs-Error: {ex.Message}");
await dialog.ShowAsync();
}
}
}
}
}
A beta of my app is available here: https://www.microsoft.com/store/apps/9NBLGGH3MFM3
Another app with exactly the behavior when OneDrive is used is NotepadX.

Play audio in background by use BackgroundCapableMedia

In the windows8 Developer preview we can use this code to play audio in background:
mediaElement.AudioCategory = AudioCategory.Media;
In the windows8 Customer perview, It seems that we should use AudioCategory.BackgroundCapableMedia instead of AudioCategory.Media
mediaElement.AudioCategory=AudioCategory.BackgroundCapableMedia;
and I also Declare a background task in appxmanifest
<Extension Category="windows.backgroundTasks" EntryPoint="TestApp.App">
<BackgroundTasks>
<Task Type="audio" />
</BackgroundTasks>
</Extension>
but it didn't work for me and the MediaElement will throw an "MF_MEDIA_ENGINE_ERR_SRC_NOT_SUPPORTED“ exception in MediaFailed EventHandler
How should I do?
You also need to set up these event handlers:
using Windows.Media;
MediaControl.PlayPressed += MediaControl_PlayPressed;
MediaControl.PausePressed += MediaControl_PausePressed;
MediaControl.PlayPauseTogglePressed += MediaControl_PlayPauseTogglePressed;
MediaControl.StopPressed += MediaControl_StopPressed;
-
void MediaControl_StopPressed(object sender, object e)
{
myMediaPlayer.Stop();
}
void MediaControl_PlayPauseTogglePressed(object sender, object e)
{
}
void MediaControl_PausePressed(object sender, object e)
{
myMediaPlayer.Pause();
}
void MediaControl_PlayPressed(object sender, object e)
{
myMediaPlayer.Play();
}
I think that should have it working.

Silverlight Image Panning

I am working on silverlight application and I want to panning image like top, bottom, left, right how I can panning the image.
I had use the pixel shadering but I am not success of this.
thanks..
Have a look at this sample
You could also look at the Blend behavior for dragging.
This worked for me. User can preview an enlarged image using this window, and pan the image to the sections that is more relevant, e.g. the bottom part of the image.
To use the window:
BitmapImage BMP = /* resolve the bitmap */;
PreviewImageWindow.Execute(BMP);
The code (behind) for the window is shown below.
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Imaging;
namespace ITIS.Controls.LinearViewer.Windows {
public partial class PreviewImageWindow : ChildWindow {
/// <summary>See Execute</summary>
PreviewImageWindow() {
InitializeComponent();
}
private void OKButton_Click(object sender, RoutedEventArgs e) {
this.DialogResult = true;
}
private void CancelButton_Click(object sender, RoutedEventArgs e) {
this.DialogResult = false;
}
static public void Execute(BitmapImage imageSource) {
PreviewImageWindow Window = new PreviewImageWindow();
Window.Image.Source = imageSource;
/* don't allow the window to grow larger than the image */
Window.MaxWidth = imageSource.PixelWidth;
Window.MaxHeight = imageSource.PixelHeight;
Window.Show();
}
private void ChildWindow_KeyDown(object sender, KeyEventArgs e) {
if (e.Key == Key.Escape) {
DialogResult = false;
}
}
Point? _lastPoint;
bool _isMouseDown;
private void image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) {
((Image)sender).CaptureMouse();
_isMouseDown = true;
ShowCursor(e.GetPosition(Canvas));
_lastPoint = e.GetPosition((Image)sender);
}
private void image_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) {
((Image)sender).ReleaseMouseCapture();
_isMouseDown = false;
ShowCursor(e.GetPosition(Canvas));
_lastPoint = null;
}
private void image_MouseMove(object sender, MouseEventArgs e) {
if (_lastPoint != null) {
Image Image = (Image)sender;
Point CurrentPoint = e.GetPosition(Image);
double
XDelta = CurrentPoint.X - _lastPoint.Value.X,
YDelta = CurrentPoint.Y - _lastPoint.Value.Y;
_lastPoint = null;
if (XDelta != 0) {
double NewLeft = Canvas.GetLeft(Image) + XDelta;
if (NewLeft <= 0 && NewLeft + Image.ActualWidth >= Canvas.ActualWidth) {
Canvas.SetLeft(Image, NewLeft);
}
}
if (YDelta != 0) {
double NewTop = Canvas.GetTop(Image) + YDelta;
if (NewTop <= 0 && NewTop + Image.ActualHeight >= Canvas.ActualHeight) {
Canvas.SetTop(Image, NewTop);
}
}
_lastPoint = e.GetPosition(Image);
}
Point CanvasPoint = e.GetPosition(Canvas);
ShowCursor(CanvasPoint);
}
private void Canvas_Loaded(object sender, RoutedEventArgs e) {
TryDefaultImageToTop();
}
void TryDefaultImageToTop() {
if (Image == null || Canvas == null) { return; }
/* move the image up so we can focus on the road? user-friendly since we are most-likely going to look at the road, not the horizon or top - half */
if (!_initialized) {
_initialized = true;
Canvas.SetTop(Image, Canvas.ActualHeight - Image.ActualHeight);
Canvas.SetLeft(Image, (Canvas.ActualWidth - Image.ActualWidth) / 2);
}
}
bool _initialized;
private void image_Loaded(object sender, RoutedEventArgs e) {
TryDefaultImageToTop();
}
private void image_MouseEnter(object sender, MouseEventArgs e) {
imgOpenHand.Visibility = Visibility.Visible;
imgClosedHand.Visibility = Visibility.Collapsed;
ShowCursor(e.GetPosition(Canvas));
}
void ShowCursor(Point point) {
if (_isMouseDown) {
imgClosedHand.Visibility = Visibility.Visible;
imgOpenHand.Visibility = Visibility.Collapsed;
Canvas.SetLeft(imgClosedHand, point.X);
Canvas.SetTop(imgClosedHand, point.Y);
}
else {
imgClosedHand.Visibility = Visibility.Collapsed;
imgOpenHand.Visibility = Visibility.Visible;
Canvas.SetLeft(imgOpenHand, point.X);
Canvas.SetTop(imgOpenHand, point.Y);
}
}
private void image_MouseLeave(object sender, MouseEventArgs e) {
imgOpenHand.Visibility = Visibility.Collapsed;
imgClosedHand.Visibility = Visibility.Collapsed;
}
}
}
The XAML for the window is shown below:
<controls:ChildWindow
x:Class="ITIS.Controls.LinearViewer.Windows.PreviewImageWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
Background="#383838" Foreground="WhiteSmoke"
Title="Preview" Margin="50"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
KeyDown="ChildWindow_KeyDown"
>
<Grid x:Name="LayoutRoot" Margin="0" Cursor="None" IsHitTestVisible="True">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Canvas Cursor="None" IsHitTestVisible="True" x:Name="Canvas" Loaded="Canvas_Loaded">
<Image Source="{Binding ImageSource}" x:Name="Image"
Cursor="None" Loaded="image_Loaded"
MouseLeftButtonDown="image_MouseLeftButtonDown"
MouseLeftButtonUp="image_MouseLeftButtonUp"
MouseMove="image_MouseMove"
MouseEnter="image_MouseEnter"
MouseLeave="image_MouseLeave"
IsHitTestVisible="True"
/>
<Image Style="{StaticResource HandOpenImage}" x:Name="imgOpenHand"
Visibility="Collapsed" IsHitTestVisible="False"
/>
<Image Style="{StaticResource HandClosedImage}" x:Name="imgClosedHand"
Visibility="Collapsed" IsHitTestVisible="False"
/>
</Canvas>
</Grid>
A few CATCHES / COMMENTS about this code:
The namespace for this window is "ITIS.Controls.LinearViewer.Windows", please change the namespace to something more relevant in your system.
The normal cursor image is and when the mouse button is down, the image changes to
The styles for the images, which I have in a global application wide resource dictionary:
(OPEN image style)
<Style TargetType="Image" x:Key="HandOpenImage">
<Setter Property="Source" Value="/ITIS.Controls.LinearViewer.Silverlight;component/Images/HandOpen.png" />
<Setter Property="Width" Value="16" />
<Setter Property="Height" Value="16" />
</Style>
(CLOSED image style)
<Style TargetType="Image" x:Key="HandClosedImage">
<Setter Property="Source" Value="/ITIS.Controls.LinearViewer.Silverlight;component/Images/HandClosed.png" />
<Setter Property="Width" Value="13" />
<Setter Property="Height" Value="11" />
</Style>
This preview tries to START with focus on the bottom half of the image, NOT the top half.
Hope this helps. It took me a while to iron out a few irritations.