Xamarin DisplayAlert not work on android live player - c#

I use DisplayAlert in my project for displaying content of page, it works on UWP(universal Windows) local machine. But when i try to use this application on Xamarin live player on Android my button does not want work.
my code in button_Clicked:
WebClient myWebClient = new WebClient();
Page p = new Page();
byte[] myDataBuffer = myWebClient.DownloadData(URL);
var download = Encoding.ASCII.GetString(myDataBuffer);
p.DisplayAlert("page:", download, "close");
Difrent button without DisplayAlert works well in Live player.

The live player has many limitations. It's better to test your app on an emulator or test it on a real device through a USB-cable.
And I think you should just call this.DisplayAlert("page:", download, "close") instead of p.DisplayAlert("page:", download, "close");

Related

Xamarin ios song does not always play on speaker

I am user Xamarin fomrs text to speech api click here to see
I have manage to implemented it on my app but some time the song play on phone speaker and some speak on earphone after record the song
Question:
How to make the song always play on phone's speaker
Here is the code :
var config = SpeechConfig.FromSubscription("xxxx", "xxxx");
config.SpeechSynthesisVoiceName = MicosoftTranslater.MySpeakerlanguagesList( "fr-FR");
var synthesizer = new SpeechSynthesizer(config);
await synthesizer.SpeakTextAsync("I am playing from phone speaker");
Thanks for your help
The key is calling the SetCategory with the appropriate AVAudioSessionCategory and setting the session to active.
Like:
var session = AVAudioSession.SharedInstance();
session.SetCategory(AVAudioSessionCategory.Playback);
session.SetActive(true);
You could use DependencyService to set it in your ios project.You could refer to https://learn.microsoft.com/en-us/answers/questions/320860/isimpleaudioplayer-issues-on-ios-and-with-speechre.html.

C# wpf how to stream webcam to ip address (possibly with Vlc)

I need to stream a webcam to an ip address.
After days of googling I decided that the easiest way was to embed Vlc.
That said I am also still open to other solutions.
Step1 - OK!: I can see my webcam in a form by using that code:
vlcPlayer.MediaPlayer.VlcLibDirectory = new DirectoryInfo(#"c:\Program Files (x86)\VideoLAN\VLC\");
vlcPlayer.MediaPlayer.EndInit();
vlcPlayer.MediaPlayer.Play(new Uri(#"dshow://");
Step2 - OK!: Now trying to make a step forward and using this tutorial I can send a video locally 127.0.0.1:5004 using 2 instances of Vlc: one to transmit and one to receive.
Step 3 - NOT OK: it should seem simple to configure vlc for changing the source from file to webcam and to transmit it via ip.
So what I do is to operate as before only changing the source:
1. Menu "Media" --> Stream. That opens the "open media" window.
Here I click the tab capture device --> video device name --> I choose "integrated webcam"
Then all the rest is as before. But nothing happens. The receiver is black with nothing inside. Also If I try to save the flow from the receiver I only get a few bytes.
The afore mentioned settings for the transmitter are the following:
Capture device tab --> integrated webcam. Then the stream button --> the window opens correctly with dshow:\ --> next --> new destination RTP,MPEG transport stream ---> add button --> address = 127.0.0.1 port = 5004 StreamNAme=test
So the strange is that when I stream a file with whatever name from the transmitter, it immediately is recognized by the receiver. Instead try as I might, nothing happens when the webcam is the source.
That being said the problem above is not crucial to the solution.
What I care for is not how to use vlc stand alone but how to use it from my wpf application in order to send the webcam stream.
Thanks for any help
Patrick
I believe this sample should help you achieve your goal:
static void Main()
{
var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
// Default installation path of VideoLAN.LibVLC.Windows
var libDirectory =
new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
using (var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory))
{
var mediaOptions = new[]
{
":sout=#rtp{sdp=rtsp://127.0.0.1:554/}",
":sout-keep"
};
mediaPlayer.SetMedia(new Uri("http://hls1.addictradio.net/addictrock_aac_hls/playlist.m3u8"),
mediaOptions);
mediaPlayer.Play();
Console.WriteLine("Streaming on rtsp://127.0.0.1:554/");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
You will need 2 nuget packages: Vlc.DotNet (C# wrapper) and VideoLAN.LibVLC.Windows (LibVLC library for Windows).

How can i create Flashlight app in uwp C#

I have Lumia 830 and i've tried to create flashlight app in UWP C#. my device Flashlight works great but i don't know why i can't create my own app turn on / off Torch of my phone.
I use Lamp class :
var lamp = await Lamp.GetDefaultAsync();
if (lamp == null)
{
ShowErrorMessage("No Lamp device found");
return;
}
lamp.IsEnabled = true;
when run this code on my phone "lamp" is null and it couldn't find my FlashLED. I've got this code from MSDN.Microsoft.com and thay said
If the returned object is null, the Lamp API is unsupported on the
device. Some devices may not support the Lamp API even if there is a
lamp physically present on the device.
This class doesn't work on my Lumia 830 i don't kno why? :(
also i use this code :
var mediaDev = new MediaCapture();
await mediaDev.InitializeAsync();
var videoDev = mediaDev.VideoDeviceController;
var tc = videoDev.TorchControl;
if (tc.Supported)
{
// But wait, for this to work with Blue camera drivers, we have to Start a recording session
// Create video encoding profile as MP4
var videoEncodingProperties = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Vga);
// Start Video Recording
var videoStorageFile = await KnownFolders.VideosLibrary.CreateFileAsync("tempVideo.mp4", CreationCollisionOption.GenerateUniqueName);
await mediaDev.StartRecordToStorageFileAsync(videoEncodingProperties, videoStorageFile);
// Turn on Torch
mediaDev.VideoDeviceController.TorchControl.Enabled = true;
}
this code works and my FlashLED turn on but it record video and it take's user SD Card memory.
please help me if you know there is best way to turn on/off Torch or FlashLED.
thanks in advance
Hussein Habibi Juybari
The Lamp API is designed for Windows 10 devices only and you can only use it on devices which support the API. Currently supported devices are 950/950XL, 650, and 550. Older devices will not be updated to support this API. You should fall back to the Windows 8.1 method of turning on flash when you detect that the lamp device is not available on older devices.
From: https://wpdev.uservoice.com/forums/110705/suggestions/15846967
Please test default sample named LampDevice (cf. https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/LampDevice). Do you have the same behavior ? I just tested on Lumia 930 it works fine. No Lumia 830 to test it.

I'm try to share text on Whatsapp in wp8

I'm try to share text on whtsapp where below method not show the whtsapp messanger.
ShareStatusTask shareStatusTask = new ShareStatusTask();
shareStatusTask.Status = jokeId;
shareStatusTask.Show();
But How can i share the text on whtsapp or other messanger
This is how I called whatsapp from my app but I haven't tried anything with sending some data to it. You will have to check it somewhere in their documentation.
private async void SendWhatsAppMessage()
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("whatsapp:"));
}
You can try the Share Link Task as follows-
ShareLinkTask shareLinkTask = new ShareLinkTask();
shareLinkTask.Title = "Code Samples";
shareLinkTask.LinkUri = new Uri("http://code.msdn.com/wpapps", UriKind.Absolute);
shareLinkTask.Message = "Here are some great code samples for Windows Phone.";
shareLinkTask.Show();
Share Link Task is a little different from Share Status Task.
In both cases your app is sending some data to share, but the other application (whatsapp in this case) must also accept the data your app is sending.
But Whatsapp currently does not support ShareLinkTask or ShareStatusTask.
You should implement these in your application code. when whatsapp starts supporting them, it will appear in the list and it will be possible to share data directly with whatsapp.

MediaPlayerLauncher on WP7 - how to resume previously playing media?

I'm using a MediaPlayerLauncher to show movietrailers in my WP7 application, like this:
MediaPlayerLauncher mpl = new MediaPlayerLauncher();
mpl.Media = new Uri(trailerUrl, UriKind.Absolute);
mpl.Controls = MediaPlaybackControls.All;
mpl.Show();
This works just fine, except one thing: if the user is already listening to music in the background, and launch a trailer, the music is not resumed after the trailer is done playing (or if the user closes the video).
Does anyone know how i can resume the previously playing music/media, if even possible?
Local media playing through XNA or a 'background audio agent'?
When you play media in WP7 / WP8, the OS audio context is taken, and the original context is lost. If the audio was launched from an external application, then you cannot resume at all. If the previous media was launched from within your application, then you could store the meta-data and re-play once your trailer is finished. The media would, of course, then begin playing from the start, rather than where the user left off. Unfortunately XNA does not allow you to seek within a given piece of media; however you can seek within an 'audio agent' instance of 'BackgroundAudioPlayer' by setting player.Position. It's also worth looking at the MediaHistory API:
var nowPlaying = Microsoft.Devices.MediaHistory.Instance.NowPlaying;
Figured it out. Calling MediaPlayer.Resume() right after show() solves the issue:
mpl.Media = new Uri(trailerurl, UriKind.Absolute);
mpl.Controls = MediaPlaybackControls.All;
mpl.Show();
MediaPlayer.Resume();
However, i would still like to know how to resume radio and spotify!

Categories