How to independently change the volume of two different MediaPlayers in Android Studio? - android-studio

I'm trying to create an app that can play two different media files, say Ambience.mp3 and fgAudio.mp3. I've created two different MediaPlayers, say ambienceMP and fgAudioMP.
Playing both the files at the same time is not an issue. I want to add two sliders that can control the volumes of each of the files separately. However, setVolume() doesn't work in this case and the other solutions that I found recommend different methods which seem overly complicated for this simple task (programming in a nutshell).
Is there a simple way to fix this, or do I need to import some library? I would highly appreciate some simple code that uses hard-coded volumes for each of the files, I can extend it to sliders myself.
I'm not sure if this is relevant, but I'm using Kotlin and not Java.

Related

The best way to load an openstreetmap .osm in a docker-container

My intentions:
Actually, I intend to:
implement vehicles as containers
simulate/move these containers on the .osm maps-based roads
My viewpoint about the problem:
I have loaded the XML-based .osm file and processed it in python using xml.dom. But I am not satisfied with the performance of loading the .osm file because later on, I will have to add/create more vehicles as containers that will be simulated onto the same road.
Suggestions needed:
This is my first time to solve a problem related to maps. In fact, I need suggestions on how to proceed by keeping in mind, the performance/efficiency, with this set of requirements. Suggestions in terms of implementation will be much appreciated. Thanks in advance!
Simulating lots of vehicles by running lots of docker containers in parallel might work I suppose. Maybeyou're initialising the same image with different start locations etc passed in as ENV vars? As a practical way of doing agent simulations this sounds a bit over-engineered to me, but as an interesting docker experiment it might make sense.
Maybe you'll need a central thing for holding and sharing the state (positions of other vehicles) and serving that back to the multiple agents.
The challenge of loading an .osm file into some sort of database or internal map representation doesn't seem like the hardest part, and because it may be done once on initialisation and imagine it's not the most performance critical part of this.
I'm thinking you'll probably want to do "routing" through the road network (taking account of one ways etc?), giving your agents a purposeful path to follow to a destination. This will get more complicated if you want to model interactions with other agents e.g. you might want to model getting stuck in traffic because other agents are going the same way, and even decisions to re-route because of traffic, so you may want quite a flexible routing system, perhaps self-coded.
But there's lots of open source routing systems which work with OSM data, to at least draw inspiration from. See this list: https://wiki.openstreetmap.org/wiki/Routing#Developers
Popular choices like OSRM are designed to scale up to country size or even global openstreetmap data, but I imagine that's overkill for you (you're probably looking at simulating within a city road network?). Even so. Probably easy enough to get working in a docker container.
Or you might find something lightweight like the code of the JOSM routing plugin easier to embed in your docker image and customize (although I see that's using a library called "JGraphT")
Then working backwards from a calculated route you can calculate interpolated steps along that path which will allow you to make your simulated agents take a step on each iteration (simulated movement)

Building Recognition in Vuforia&Unity

I would like to make a mobile application so that when a user points at a building it will render various information. My problem is that I really don't know if this can be done. I mean the only way is to take an image of the building and upload it as an image target in unity. But what if the image will change over time (vegetation?) or the user points the camera from a different perspective than the one I used?
Is there a way to make this so that the problem mentioned above won't be an issue?
You can approach this in several ways (or even combine them together):
Write a mechanism that will be able to download updated Vuforia datasets from a server into your app in runtime. This way, you can update the building images when you wish, and ensure it will be detected if something changes
Make sure you take enough pictures of the building from enough perspectives. You can use many images of the building in a single Vuforia dataset
Try to find a partial sections or sections of the building that is very likely to remain unchanged.

Google Keep-like Layout with Polymer

I want to make a web app that uses a UI similar to Google Keep. I want to be able to have chips of the same size that can be dynamically added/removed that expand into larger cards with more options. What kind of layout should I use in Polymer?
Here are some quick sketches of what I want to accomplish.
There's likely a number of ways you can go, probably best you just try some things & find the approach you like. To help get started I think some of the core-animated-pages demos would help. Here are a couple that you may be able to leverage to get sort of close to your design:
https://www.eecs.berkeley.edu/~gongliang13/polymer/polymer-tutorial-master/components/core-animated-pages/demos/grid.html
https://www.eecs.berkeley.edu/~gongliang13/polymer/polymer-tutorial-master/components/core-animated-pages/demos/music.html

GWT-GXT Containers and Layouts Overview

Anybody know of a good description of containers/layouts/panels/etc for GXT? All the tutorials I've seen usually pick one or two and just use them. Nobody seems to explain the who/what/when/where/how of using various combinations.
Thanx,
~r
PS
Actually I have a slightly complex app (~150 java classes; 8 separate tabs with lots of grids, and lists and tons of RPC calls). Seems my grids are not displaying a horizontal scroll-bar and I suspect it's because I'm using some container/layout combination that prevents it (not FitLayout ;-)
Best source to know about the container, layouts is GXT samples. They are available if you download GXT. You can also checkout the examples in the GXT site. Here is the link

What would you recommend to do simple 2D Graphics?

I want to build a program that will (as part of what it's doing) display lines organically growing and interacting horizontally across the screen. Here's a sample image, just imagine the lines sprouting from the left and growing to the right:
The lines would look like the lines used on Google Maps Transit Overlay or OnNYTurf's transit pages.
It's a personal project, so I'm open to just about any language and library combination. But I don't know where to start. What have you used in the past to create graphics that are similar to this? What would you recommend? I want it to run on Windows without any extras needed (.Net is fine), and it doesn't have to run elsewhere. I needs to run as an actual program, not javascript in the browser.
There's obviously no 'right' answer to this, but the purpose isn't to start an argument about X better than Y but rather just find a list of graphics toolkits that do simple 2D graphics that people recommend because of their ease of use or community or whatever.
Processing may be just the tool for you.
Like you said, there are many ways to tackle this problem. Me personally, being it is a windows based project, I would go with the .NET based implementation utilizing WPF. There are tutorials on how to use the 2D drawing feature out there ( http://www.wpftutorial.net/DrawOnPhysicalDevicePixels.html for one ) Again, there is no right answer here. I might also pick some new technology and let your project be a mechanism to learn something new, providing you do not have a looming deadline.

Resources