Status listener on mediaplayer object in javafx 2 - listener

I'm trying to make a media player with playlist in Javafx2.
I'm struggling because I want the playlist to advance to the next song when the current song ends. I was expecting a listener interface that I could implement in my playlist class but all that is on offer is that of a runnable.
Does anyone have any experience using this API that may help me?

Implement a Runnable for the setOnEndOfMedia method.
See this sample code which plays a list of audio files.
I think the media events should have been handled by EventHandlers rather than Runnables and requested that they be updated to work with EventHandlers but that requires a possibly incompatible API change which hasn't been implemented yet. So for now just use the Runnables - they work fine even though their method signatures are inconsistent with the rest of the JavaFX system.

Related

How to Simulate a Keyboard Event in Dart HTML

1. Problem and Context
I'm trying to create a browser extension with Dart, more specifically, one that deals with adding keyboard shortcuts to certain websites.
To guarantee better TDD, I'm trying to simulate keyboard events during the tests. However, it seems like many things have changed when it comes to Dart's HTML APIs and I haven't been able to figure out how to make them work.
2. What I'm Trying
I would like to register a specific keystroke — so the generic KeyboardEvent won't cut it apparently, only the KeyEvent class can handle that. So far, I'm trying something like this:
document.body.dispatchEvent(KeyEvent('keypress', keyCode: 65, charCode: 97));
From which I receive an error close to this:
Error: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.
I've also tried the code above with document, document.window and window, none worked. Something similar can be found in the KeyEvent documentation. However, they mention adding to a Stream, which I don't think is possible. It would have to be a Sink instead.
If I'm not able to solve this via dispatching events, I think I'll have to simply inject mocks into the tests.
3. More Resources
2 outdated answers which have helped me so far were:
dart how to create, listen, and emits custom event?
How do I listen for custom events in Dart?

How to add CuePoint to a rtmp stream with ActionScript 3.0

I am trying to build a teaching application using flash player. My idea is that when the teacher does something, such as changing the slides, the javascript calls the SWF interface which adds CuePoints to the rtmp stream, while the students listening on the CuePoint event, they are able to synchronize what the teacher is doing.
So I did my research and found out that I had to write some server-side script/module to support this. I tried Wowza Server and wrote a Java Module which defined a handler function so the AS was able to call
netconnection.call("handler_function", null, "myStream", arg1, arg2);
But sadly, I am using a third-party streaming cloud so I can't write server-side code. Is there any way to add the CuePoint only on the client side with ActionScript?
Dont have enough to mark a comment so posting it here. I did not use FMS/wowza recently, but using FMS I used to do this like the example at https://forums.adobe.com/thread/1152718?tstart=0
hope this will work same on wowza too. Thanks

ServiceLocationProvider is null when launched as a Share Target

I'm using MVVM Light and everything is fine except when launching my Windows Phone 8.1 WinRT app as a Share Target.
When I try to assign MainViewModel viewModel = ServiceLocator.Current.GetInstance<MainViewModel>(); I get an exception for ServiceLocator.Current.
Exception Message: ServiceLocationProvider must be set.
Do I need to do something extra in App.xaml.cs OnShareTargetActivated event to insure the Locator is running?
UPDATE:
A ShareTarget page needs to be thought of as a small extension of your app. It seems that not all of the app's resources are loaded (including app-wide resources in App.xaml). So I just created a new instance of MainViewModel in the share page's constructor, loaded only the things I need for the share to complete, save the information and call ShareOperation.ReportCompleted. This returns the user back to the app that is sharing.
I still haven't found a good solution for getting other resources in my ViewModel, but this works for now.
This indicates that the following line has not been executed:
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
This line will instruct the ServiceLocator class to use the SimpleIoc.Default instance as its ServiceLocator.Current. When you run your app as a Share target, the initialization is slightly different and probably the ViewModelLocator doesn't get initialized. You need to find a good location to perform the initialization before you use the ServiceLocator.
Cheers
Laurent

Can an embedded cocos2d-js app call back out to c++?

I'm researching the possibility of using cocos2d-js by embedding it as a view inside an existing iOS app. In order to make this work, I'm going to need 2-way communication between cocos2d and the surrounding application.
After some initial investigation, I have determined that it is possible to call in to cocos using ScriptingCore:
ScriptingCore* sc = ScriptingCore::getInstance();
jsval outVal;
sc->evalString("function()", &outVal);
My question, then, is around doing the reverse. It is possible to (e.g. in response to user input) call back out of cocos2d-js to C++? Ideally, there would be a way to register a callback with ScriptingCore which could be invoked from JavaScript.
I believe it can be done, but I have not tried myself, nor can I find a good and concise example.
All I can do is point you at SuperSuraccoon's Bluetooth example and it's git page, which apparently does both ways communication between C++ and JS code.

How to have variables accessible across keyframes- AS3

I'm working on a portfolio suggestion application in Flash, which consists of two views: ask user for 3 to 4 points of information, and display recommendations based on that information.
The first view is going swimmingly, as all I need are the graphics to be created. However, I'm having trouble understanding how a AS3 variable can be seen across keyframes when it was declared and initialized on the first frame.
The only multi-view app I've done is a Restaurant Guide flash app that was described in Adobe Flash CS5 Classroom in a Book. In that example, the only AS function on four of the views
was a stop() function.
If I were to do the same in this app, and declare the variables as global in the first frame, will they be accessible throughout?
CLARIFICATION
Two comments have said that my question is unclear, so I hope this makes my question more understandable. I want to know how, if I gather all the user information on Frame 1 and then switch to a view on Frame 15, to access those variables on Frame 1.
This isn't really the way you're supposed to work in AS3. Each view should be an object in your library with an associated class. Your document should also have a class associated with it, and it is here that you would hold your common data. The document class would instantiate each view as it is required and pass in the relevant variables.
That said, if you want to work the old way you shouldn't have trouble declaring a variable on frame 1 like this:
var myVar:String = "Hello!";
and then accessing it on frame 15 of the same timeline like this:
trace(myVar);
If that's what you're doing and it's not working then you'll need to update your question with some code examples.