What do I put as cast.receiver.RemoteMedia.NAMESPACE? - chromecast

On the receiver examples I always see cast.receiver.RemoteMedia.NAMESPACE used. Is that supposed to be replaced by my own name? I tried using 'ramp' I also tried 'myownnamespace' and 'ramp','myown' and all of those with brackets around them. Any time I change it from cast.receiver.RemoteMedia.NAMESPACE my code stops working. Below is the code I am talking about:
var receiver = new cast.receiver.Receiver(
'YOUR_APP_ID_HERE',
[cast.receiver.RemoteMedia.NAMESPACE],
"",
5);
var remoteMedia = new cast.receiver.RemoteMedia();
remoteMedia.addChannelFactory(
receiver.createChannelFactory(cast.receiver.RemoteMedia.NAMESPACE));
I also tried something I found on the document, didn't work either.
var receiver = new cast.receiver.Receiver('myappid', ['ramp', 'other']);
var rampHandler = new cast.receiver.RemoteMedia();
rampHandler.addChannelFactory(receiver.createChannelFactory('ramp'));
var channelHandler = new cast.receiver.ChannelHandler('other');
channelHandler.addChannelFactory(receiver.createChannelFactory('other'));
So what values should I be putting there? should my android app reference those values somewhere?
Thanks.

The "cast.receiver.RemoteMedia.NAMESPACE" is for media playback using the HTML5 video tag. That channel will use the RAMP protocol for media controls. The Cast SDK provides utility classes to manage a media channel (see MediaProtocolMessageStream, MediaProtocolCommand).
If you don't want to play media then you can create your own channel with its own namespace. Look at the Tic-Tac-Toe sample app. Your channel prototype should declare your namespace in JavaScript and then that is used to initialize the receiver and add your custom channel handler.
If your app plays media then you should just have to change the 'YOUR_APP_ID_HERE' in the receiver and use the same app id in your Android code to start a session.

Related

Problem with Objective-C marshalling an "optionals" property in Nativescript

I'm building a NativeScript plugin for iOS to integrate a card payment terminal as an external accessory. It is almost done, and working, but I have problem with passing one argument called "optionals". This is the whole code I'm trying to implement. It's the payworks framework for a Miura terminal. http://www.payworks.mpymnt.com/node/143
MPTransactionParameters *tp = [MPTransactionParameters chargeWithAmount:[NSDecimalNumber decimalNumberWithString:#"5.00"]
currency:MPCurrencyEUR
optionals:^(id<MPTransactionParametersOptionals> _Nonnull optionals) {
optionals.subject = #"Bouquet of Flowers";
optionals.customIdentifier = #"yourReferenceForTheTransaction";
}];
I cannot find a way of sending this "optionals" function.
In the generate typing metadata I see the MPTransactionParametersOptionals is a #protocol, but still don't know how to use it here as a parameter.
This is my current javascript code for the block
const tp = MPTransactionParameters.chargeWithAmountCurrencyOptionals(
amount,
MPCurrencyEUR,
function (optionals) {
console.log(optionals); //logs the newly created MPTransactionParameters instance, with set amount and currency properties, but cannot touch or set the optional properties.
}
);
The 3rd parameter of chargeWithAmountCurrencyOptionals() should be a function, but I'm doing it wrong, and searched everywhere in google how to do it but no success. I'm already trying for 2 days.
It is working, when the 3rd parameter is null, but I need the set the optional properties.
EDIT: adding the metadata. There are a lot of typings for MPtransactionParameters, so I decided to give you the whole file so you can search.
https://drive.google.com/open?id=1kvDoXtGbCoeCT20b9_t2stc2Qts3VyQx
EDIT2: Adding the typings:
https://drive.google.com/open?id=1lZ3ULYHbX7DXdUQMPoZeSfyEZrjItSOS

Xamarin Forms Video Player Sample - Get Video Bytes for Uploading

I'm implementing a video player in a Xamarin Forms app just like the video player sample provided by Xamarin
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/video-player/
I'm able to select a video from the phone gallery, set the video player source to the selected video, and play the video. How do I get the actual stream or bytes of the selected video so that I can upload it to Blob Storage?
I've tried
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) ..........
where fileName is the path and file name of the selected video as set to the video player source. It doesn't work as the Android file name string is not found. (When invoking this from xamarin forms). I realize the file name will be different even when on iOS. How do I reach down into the platform specific implementations and get the file bytes or stream of the selected file?
thanks
I would look into the libVLCSharp library which provides cross-platform .NET/Mono bindings for libVLC. They provide good support for Xamarin.Forms and the features you most likely need to implement the stream handling functionality. What you're trying to achieve won't be simple but it should be perfectly doable.
First, you should check out the documentation for Stream output:
Stream output is the name of the feature of VLC that allows to output any stream read by VLC to a file or as a network stream instead of displaying it.
Related tutorial: Stream to memory (smem) tutorial.
That should get you started but there will for sure be many caveats along the way. For example, if you try to play the video while capturing the bytes to be uploaded somewhere, you'll have to respect VERY tight timeframes. In case you take too long to process the stream, it will slow down the playback and the user experience suffers.
Edit: Another option you could look into is to interact directly with the MediaPlayer class of libVLC, as explained in this answer. The sample code is in C++ but the method names are very similar in the .NET bindings.
For example, the following piece of code:
libvlc_video_set_callbacks(mplayer,
lock_frame, unlock_frame,
0, user_data);
can be implemented with libVLCSharp by calling the SetVideoCallbacks(LibVLCVideoLockCb lockCb, LibVLCVideoUnlockCb unlockCb, LibVLCVideoDisplayCb displayCb) method in the binding library, as defined here.
You can do this pretty simply by using a DependencyService. You will need to adjust the below code to cater for a folder location that you're working with but, do this.
Change all of the "Test" namespaces to you're own project.
Add an interface into your shared project called IFileSystem that looks like this ...
using System;
namespace Test.Interfaces
{
public interface IFileSystem
{
byte[] GetFileInBytes(string fileName);
}
}
Create a dependency service down in each platform project. For this, I'm only supplying iOS and Android but as you'll see, the logic for both is essentially exactly the same, only the namespace differs ...
iOS
using System;
using System.IO;
using Test.Interfaces;
using Test.iOS.DependencyServices;
using Xamarin.Forms;
[assembly: Dependency(typeof(FileSystem))]
namespace Test.iOS.DependencyServices
{
public class FileSystem : IFileSystem
{
public byte[] GetFileInBytes(string fileName)
{
var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);
fileName = Path.Combine(folder, fileName);
return File.Exists(fileName) ? File.ReadAllBytes(fileName) : null;
}
}
}
Android
using System;
using System.IO;
using Test.Interfaces;
using Test.Droid.DependencyServices;
using Xamarin.Forms;
[assembly: Dependency(typeof(FileSystem))]
namespace Test.Droid.DependencyServices
{
public class FileSystem : IFileSystem
{
public byte[] GetFileInBytes(string fileName)
{
var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);
fileName = Path.Combine(folder, fileName);
return File.Exists(fileName) ? File.ReadAllBytes(fileName) : null;
}
}
}
... now call that from anywhere in your shared project.
var bytes = DependencyService.Get<IFileSystem>().GetFileInBytes("Test.mp4");
That should work for you, again though, you need to adjust the folder path to your appropriate location for each platform project. Essentially, this line is the one that may need to change ...
var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);
Alternatively, change that code to suit your requirements. If the file path you've been given contains the fully qualified location, then remove the logic to add the folder altogether.
Here's hoping that works for you.

iOS what is the value of accessibilitySpeechIPANotation

Based on this WWDC2018 video, we can dynamically change how words are pronounced in AVSpeechSynthesizer.
I'm trying to do that in my Xamarin App, but I can't find the accessibilitySpeechIPANotation constant.
In the doc of NSMutableAttributedString.AddAttribute(...) it says that the constants can be found here: UIKit.UIStringAttributeKey. Yet the one I'm looking for isn't there.
Does anyone know what the actual string value of the constant is? Or even better, where I can find in in Xamarin.iOS?
(My app uses xamarin.ios v4.0.30319, if the constant is in a newer version of the framework, I'll update it, but google doesn't seem to give me any result when I search for it.)
Cause:
Xamarin for iOS is based on Objective-C.And there are some differences between swift and Objective-C.
Solution:
The code is just like the following :
var attriStrng = new NSMutableAttributedString(new NSString("hello iPhone"));
// you can set the voice here ,a͡͡a͡͡a͡͡a͡͡a͡͡ is just for testing
attriStrng.AddAttribute(new NSString("AVSpeechSynthesisIPANotationAttribute"), new NSString("ˈa͡͡a͡͡a͡͡a͡͡a͡͡a͡͡a͡͡.ˈfo͡ʊn"),new NSRange(6,6));
var voice = new AVSpeechUtterance(attriStrng);
AVSpeechSynthesizer synthesizer = new AVSpeechSynthesizer();
synthesizer.SpeakUtterance(voice);

How to create a VPN connection in Swift on OS X?

I followed the steps described in this tutorial.
I tried to translate the code from Objective-C to Swift. This is the code I have:
var l2tpInterface = SCNetworkInterfaceCreateWithInterface(
kSCNetworkInterfaceIPv4,
kSCNetworkInterfaceTypeL2TP
).takeUnretainedValue();
var pppInterface = SCNetworkInterfaceCreateWithInterface(
l2tpInterface,
kSCNetworkInterfaceTypePPP
).takeUnretainedValue();
var prefs = SCPreferencesCreate(nil,"SoybeanVPN",nil).takeUnretainedValue();
var service = SCNetworkServiceCreate(prefs, pppInterface).takeUnretainedValue();
var success = SCNetworkServiceEstablishDefaultConfiguration(service);
This code returns a runtime error EXEC_BAD_ACCESS(code=1) at the first line.
I googled this error and someone said the problem is caused by using released object in Objective-C? Is that the same in Swift? Does anyone have any experience with VPN creation in Swift?
UPDATE:
I tried to debug and find the const value of kSCNetworkInterfaceIPv4 is invalid, see the attached image:
Is that a bug of Swift?
I believe kSCNetworkInterfaceIPv4 is not the problem, because I can use it just fine to create L2TP/IPSec and Cisco VPNs using Swift.
It's rather tricky to handle C pointers in Swift, but this is how I do it, using Swift 2.3. Notice the wrapping/unwrapping with ! of C-Reference objects.
let initialTopInterface: SCNetworkInterfaceRef!
let initialBottomInterface: SCNetworkInterfaceRef!
// L2TP on top of IPv4
initialBottomInterface = SCNetworkInterfaceCreateWithInterface(kSCNetworkInterfaceIPv4, kSCNetworkInterfaceTypeL2TP)
// PPP on top of L2TP
initialTopInterface = SCNetworkInterfaceCreateWithInterface(initialBottomInterface!, kSCNetworkInterfaceTypePPP)
let service = SCNetworkServiceCreate(usingPreferencesRef, initialTopInterface!)
// Now you assign the attributes
SCNetworkServiceSetName(service, ("Some Name" as CFString))
// myConfiguration is a Hash with your relevant Key/Value pairs
SCNetworkInterfaceSetConfiguration(topInterface!, myConfiguration)
// Here is a good example for why Swift may just crash if you're not careful
let temporaryString:CFString = "IPSec"
SCNetworkInterfaceSetExtendedConfiguration(topInterface!, temporaryString, myL2tpConfiguration)
SCNetworkServiceEstablishDefaultConfiguration(service)
You can find a working implementation (for macOS Sierra) on Github
Just need copy all SCNetworkInterface's
SCNetworkInterfaceCopyAll()
Insert it at the beginning, before creating interfaces

Flex 4 coltware airxmail - send vCal appointment

I am using coltware.airxmail to send emails from my Flex app.
I would like to send VCalendar appointment files generated from Flex straight to Outlook so they are opened in the Calender view. I am able to send the VCal files as an attachment on an email, however, these are not "auto-opened" in Outlook Calendar, which requires the user to double click on the file.
I have been trying to set the content type of the mail to "text/x-vCalendar", and pass in a byte array containing the VCal file, however, no joy. The vCal arrives as a .txt attachment to an empty email!
I wonder if anyone has had previous experience with this kit, or can suggest any pointers?
Or even suggest another component they have used to send VCal files straight to outlook, from ActionScript?
Here's my sample code (DEMO CODE VERY MESSY JUST TO GET POINT ACROSS):
var sender:SMTPSender = new SMTPSender();
// Set the from / to / host / port values here
var contentType:ContentType = new ContentType();
contentType.setMainType("text/x-vCalendar");
var message:MimeMessage = new MimeMessage(contentType,"UTF-8");
var file:File = File.desktopDirectory.resolvePath("vcal.vcs");
file.addEventListener(Event.COMPLETE,
function(ev:Event):void {
message.addRawContent(file.data);
sender.send(message);
sender.close();
});
file.load();
Hopefully I can achieve this using the coltware component. There's nothing on their site about using these methods, although the API guide is very incomplete - just "basic usage"... http://code.google.com/p/airxmail/wiki/HowToUseAPI
Did you try using a different content type, such as "text/calendar"? see here: http://weblogs.asp.net/bradvincent/archive/2008/01/16/creating-vcalendars-programmatically.aspx

Resources