UWP how to use MediaPlayer events in MediaPlayerElement in XAML? - xaml

I have read this documentation about MediaPlayerElement and it says MediaPlayerElement contains properties of MediaPlayer class. But I couldn't figure out how can I use MediaPlayer's events on MediaPlayerElement.

As the documentation states:
The majority of the media functionality is located on the underlying MediaPlayer class, which you can access through the MediaPlayerElement.MediaPlayer property
So to use and set any events of MediaPlayer, you just use the MediaPlayer property of the MediaPlayerElement.

Related

Is it ok to send normal messages via Interface Builder's binding’s model key path?

Is it ok to send normal messages via Interface Builder's binding’s model key path?
I want to enable some menu items only if the main window of my application is visible. I simply tried the following to see what would happen:
In the bindings inspector of the menu item i bind Availability-Enabled to the AppDelegate and set the model key path to self.window.isVisible.
This seems to work well, but is it meant to be used like this? Legal in the AppStore?
A little exclamation mark appears next to my model key path..
This binding is legal if the model property (isVisible) conforms to KVO (key-value observing), because bindings are implemented using KVO.
(UPDATED) NSWindow has several documented binding keys, including the key visible. Since the standard KVC search pattern would look for isVisible for the key visible, what you're doing will probably always work. But you would be better off just binding to visible, since that's documented.
The important lesson is that you should only bind to keys that are documented for Cocoa bindings, or keys that are documented to be KVO-compliant.
The exclamation mark is Xcode's way of warning you that it doesn't know if the binding is legal. You can hover your mouse pointer over it for a tooltip:

Can a custom keyboard extension communicate with the companion app at runtime?

Can a custom keyboard communicate with the companion app at runtime? Can a custom keyboard dynamically display content based on states set in the companion app?
If so, what API’s/documentation is available for this communication between the extension and app?
Here is a nice paragraph from the documentation that could get you started in sharing data with your companion app: https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW6
I have this working with a today extension and the companion app. They both share the same NSUserDefaults so they can communicate in real time each other. If NSUserDefaults is what you're looking for, here there is a nice tutorial: http://www.glimsoft.com/06/28/ios-8-today-extension-tutorial/

Adding custom controls to Interface Builder (IB) Xcode

I did this wonderful tutorial: Photoshop Tutorial For Developers: Creating a Custom UISlider and came away with two questions:
The example above makes every UISlider customized. Can you just subclass UISlider and tweak this code to make it it's own class that can be called upon?
Further, could you make this custom control available in the object explorer within Interface Builder, so you can just drag and drop it on your view like anything else in UIKit?
The docs for CocoaTouch classes will usually indicate if a class is not designed for sub-classing. In the case of UISlider, there's also some instructions for customizing appearance.
Custom Component in Interface Builder
To use a custom component within Interface Builder, its necessary to use the "object" component, and specify the class type to your custom class. Unfortunately this does not render any visual queues, like core UIKit classes.
Your own Plugin
It may be possible to provide a plugin to tweak Xcode, however this is no small undertaking as there are no official docs, so its necessary to search for open-source plugins on GitHub, etc and study the code. Even then, the plugin may break with subsequent version of Xcode.
Recommended Approach
Interface Builder is an amazing technology, however for more complex applications I recommend implementing views in code (override loadView in the VC). Here's some reasons:
Promotes better encapsulation and reuse. You can compose your own components (eg composition vs inheritance) using UIKit components, and provide a custom OO interface to them. Contrast this with lots of IB outlets in a view controller, which leads to poor reuse.
Fat-controllers don't really honor the MVC paradigm.
More flexible and fluent. Not all properties are exposed via IB, so in a complex case, its hard to know where to look. Is that setting in IB or code? Custom fonts, for example.
Xibs are really tricky to merge in a multi-person team.

Way to modify Contact's ringtone via ABPerson class iOS?

So I've been toying around with the AddressBook framework on iOS and have noticed in the ABPerson class, pretty much every attribute of a contact is listed as a constant (ref: apple documentation). However, one attribute I notice is missing is the ability to make a custom ringtone. Is there any way to modify the ringtone of a contact via the ABPerson class? If not, is there any way at all to modify the custom ringtone using the AddressBook framework? iOS 5.1.1.

Custom string properties in interface builder

Is there a simple way to expose, say, NSString or UIColor properties of a class such that they can be modified in interface builder?
This would be useful e.g. for adding color properties to a custom view (which are then used programmatically) so that they can be manipulated in Interface Builder as is appropriate.
In iOS 8 there are two new properties added, #IBInspectable and #IBDesignable. Here's a full write up.
http://www.weheartswift.com/make-awesome-ui-components-ios-8-using-swift-xcode-6/
This article from Cocoa with Love describes how to do what you want with Interface Builder Plug-ins for Mac development. Unfortunately, it is currently not possible to use IBPlugins with the iPhone SDK (note the Interface Builder Plug-in Programming Guide only appears in Mac OS X documentation, not iOS documentation).
There is no way to add a custom "non-IBOutlet" attribute but I suggest you to add a UILabel to make use of the text attribute of it, and of cause release that when the view is loaded.