I have more than 10 mp4 videos which I am tying to embed in my web application using vaadin video component. When I run my application on Edge/IE the vidoes work fine, but on chrome they dont. Its known issue with chrome where if the page has more than 6-8 mp4 videos, it hangs as it tried to preload all of them together.
I was wondering if the video component provide me option to set the preload to none. I can see the mediabase has this option
https://vaadin.com/api/7.6.7/index.html?com/google/gwt/media/client/MediaBase.html
But I dont see it for video.
Also I found another link where they seems to do the fix https://github.com/vaadin/framework/issues/5178 , but couldnt make it work.
Any help?
Until the commit/PR in your linkgets merged, it does not in 7 or 8.
However, you can use an AbstractExtension and AbstractExtensionConnector to accomplish this.
The AbstractExtension
package com.my.package;
import com.vaadin.server.AbstractClientConnector;
import com.vaadin.server.AbstractExtension;
import com.vaadin.ui.AbstractComponent;
public class VideoPreloadExtension extends AbstractExtension {
public VideoPreloadExtension() {
}
public VideoPreloadExtension(AbstractClientConnector target) {
super(target);
}
public void extend(AbstractComponent component) {
super.extend(component);
}
}
The AbstractExtensionConnector
package com.my.package.client;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ServerConnector;
import com.vaadin.client.extensions.AbstractExtensionConnector;
import com.my.package.VideoPreloadExtension;
import com.vaadin.shared.ui.Connect;
#Connect(VideoPreloadExtension.class)
public class VideoPreloadConnector extends AbstractExtensionConnector {
#Override
protected void init() {
super.init();
}
#Override
protected void extend(ServerConnector target) {
// Get the extended widget
final Widget widget = ((ComponentConnector) target).getWidget();
widget.getElement().setAttribute("preload","auto");
}
}
Usage is as follows:
Video image = new Video();
VideoPreloadExtension ext = new VideoPreloadExtension();
ext.extend(image);
Some Notes (because vaadin can be a pain at times)
If you have a library module already, its best to add the above classes to it.
Confirm that the module you add these classes to has the following dependency add so the widgetset will get compiled:
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client</artifactId>
</dependency>
Remember that the VideoPreloadConnector needs to be in a package name that ends with ".client".
Here is a screenshot of an inspect element from chrome of it working:
HTHs!
Related
I am trying to apply a texture to an item created with forge for Minecraft but for some reason it wouldn´t load. I am new to this so I cant recognize where the problem is, so I will upload multiple lines of code.
This code is from itemInit.Java:
package com.example.examplemod.init;
import com.example.examplemod.ExampleMod;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.registries.ObjectHolder;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
#Mod.EventBusSubscriber(modid = ExampleMod.MOD_ID, bus = Bus.MOD)
#ObjectHolder(ExampleMod.MOD_ID)
public class itemInit {
public static Item example_item = null;
#SubscribeEvent
public static void registerItems(final RegistryEvent.Register<Item> event) {
event.getRegistry().register(new Item(new Item.Properties().group(ItemGroup.MISC)).setRegistryName("example_item"));
}
}
This is the example_item.json:
{
"parent":"items/generated",
"textures":{
"layer0":"examplemod:items/example_item"
}
}
en_us.json:
{
"item.examplemod.example_item":"Super Seed"
}
And here is a picture of the project hierarchy:Project hierarchy
In your example_mod.json file, line 2, change it to
"parent": "item/generated",
Inside the directory assets\examplemod\models, you have two folders named blocks and items. Change their names to 'block' and 'item' without the quotation marks. If you encounter any other problem, post your error log using pastebin or some other site. Also, create a github repo for your project and then post the link here :)
Also, I recommend using DeferredRegister class and RegistryObjects to register your custom items.
Syntax:
public static final DeferredRegister<Item> NAME = new DeferredRegister<>(ForgeRegistries.ITEMS, "Your Mod ID");
public static final RegistryObject<Item> Example_item = NAME.register("Registry_Name", () -> new Item(new Item.Properties()));
Downloaded latest android Studio (android-studio-bundle-162.3871768-windows).
We were using com.android.sdklib.SdkManager class in our software but in latest Android Studio I'm not able to find the above mentioned class in any jar present inside the tools\lib folder.
Can anyone suggest what is the better alternative for this?
if you want to get a list of all the targets installed for knowledge, then you can just simply run the SDK manager. But since you want to call the getTargets() method, it means you need it for other purposes. check up the documentation on the android studio web page to find out if it the class you are searching for exists and the location of its jar file.
We can find the soure code of all the android classes in the below link.
https://javalibs.com/artifact/com.android.tools/sdklib?className=com.android.sdklib.tool.SdkManagerCli&source
SdkManagerCli class have equivalent method listPackages()which will list the packages.
We need to import sdklib-25.3.2.jar, repository-25.3.2.jar and common-25.3.2.jar to project.
Below is the working code for listing packages:-
import java.io.File;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.TreeSet;
import com.android.repository.Revision;
import com.android.repository.api.ConsoleProgressIndicator;
import com.android.repository.api.LocalPackage;
import com.android.repository.api.ProgressIndicator;
import com.android.repository.api.RepoManager;
import com.android.repository.impl.meta.RepositoryPackages;
import com.android.sdklib.repository.AndroidSdkHandler;
public class AndroidTesting {
public static void main(String[] args) {
listPackages();
}
private static void listPackages() {
AndroidSdkHandler mHandler = AndroidSdkHandler.getInstance(new
File("filePath")); //for eg:-sdk/platforms for API
ProgressIndicator progress = new ConsoleProgressIndicator();
RepoManager mRepoManager = mHandler.getSdkManager(progress);
mRepoManager.loadSynchronously(cacheExpirationMs, progress,
downloader, settings)(0, progress, null, null);
RepositoryPackages packages = mRepoManager.getPackages();
Collection<LocalPackage> locals = new TreeSet<LocalPackage>();
Collection<LocalPackage> localObsoletes = new
TreeSet<LocalPackage>();
for (LocalPackage local : packages.getLocalPackages().values()) {
if (local.obsolete()) {
localObsoletes.add(local);
} else {
locals.add(local);
}
Revision version = local.getVersion();
System.out.println(local.getDisplayName() + " "
+ local.getVersion() );
}
}
}
Im just getting into developing modules for Xposed Framework.
I get a basic module working, just a module that does nothing but saying that its loaded and prints to log.
Next step was to try hooking the Clock in SystemUI, following rovo89's instructions on GitHub (dont know if I can link?)
The code is as follows:
package com.example.xxx.xposedtest;
import android.graphics.Color;
import android.widget.TextView;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
import de.robv.android.xposed.XposedHelpers;
public class xposedTest implements IXposedHookLoadPackage {
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if(!lpparam.packageName.equals("com.android.systemui")) {
XposedBridge.log("Did not find package")
return;
}
findAndHookMethod("com.android.systemui.statusbar.policy.Clock", lpparam.classLoader, "updateClock", new XC_MethodHook() {
#Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
TextView tv = (TextView) param.thisObject;
String text = tv.getText().toString();
tv.setText(text + " :)");
XposedBridge.log("Package loaded: Function ran");
}
});
}
}
The log says "Did not find package". And the hook method ofcourse did not run.
My guess is that Samsung s7 edge has some kind of other implementation, other class/method name.
How do I find out what method to actually hook since Samsung decided to not go AOSP? All information on the subject is appriciated.
The answer was other xposed modules were interfering.
Answering if anyone encounters the same problem
Here in webcenter-driven ADF application we have a standard library called generic-site-resources-model.jar which contains file META-INF/service-definition.xml, which i wish to alter at one line, to add view resource' security permission, as in:
## -1189,7 +1189,7 ##
<resource-permission>
<resource-permission-impl>oracle.webcenter.security.auth.WebCenterResourcePermission</resource-permission-impl>
<resource-permission-target-id>resource_oracle_webcenter_siteresource_#scope#_navigation_#resource#</resource-permission-target-id>
- <resource-permission-action-list>manage,update</resource-permission-action-list>
+ <resource-permission-action-list>view,manage,update</resource-permission-action-list>
</resource-permission>
</permission-metadata>
</security-definition>
How this is can be possibly done without alterning weblogic domain containing this library itself, somehow configuring our application? Maybe some way to override the whole generic-site-resources-model.jar with application-shipped clone? Or (ideally) some way to replace the targeted resource permission? Or some custom way of taking control over resource loading in application?
It is possible to implement appending custom actions to specific resource type using initialization phase listener and a little bit code, without any overriding at all.
Here is how:
ViewControllerProject/src/META-INF/adf-settings.xml
<?xml version="1.0" encoding="UTF-8" ?>
<adf-settings xmlns="http://xmlns.oracle.com/adf/settings">
<adfc-controller-config xmlns="http://xmlns.oracle.com/adf/controller/config">
<lifecycle>
<phase-listener>
<listener-id>PortalInitializer</listener-id>
<class>com.otr.portal.initializer.PortalInitializer</class>
</phase-listener>
</lifecycle>
</adfc-controller-config>
</adf-settings>
com.otr.portal.initializer.PortalInitializer
package com.otr.portal.initializer;
import oracle.adf.controller.v2.lifecycle.Lifecycle;
import oracle.adf.controller.v2.lifecycle.PagePhaseEvent;
import oracle.adf.controller.v2.lifecycle.PagePhaseListener;
import oracle.webcenter.security.internal.common.SecurityUtil;
import oracle.webcenter.security.model.exception.SecExtensionNotFoundException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class PortalInitializer implements PagePhaseListener {
private static final Log log = LogFactory.getLog(PortalInitializer.class);
private boolean firstCall = true;
#Override
public void afterPhase(PagePhaseEvent pagePhaseEvent) {
if (pagePhaseEvent.getPhaseId() == Lifecycle.INIT_CONTEXT_ID) {
if (firstCall) {
setupViewNavigationResourcePermssion();
firstCall = false;
}
}
}
private void setupViewNavigationResourcePermssion() {
try {
SecurityUtil.getSecurityExtension("oracle.webcenter.siteresources.navigation").getExtensionPermMetadata().getResourcePermMetadata().getResourcePermActionsList().add("view");
} catch (SecExtensionNotFoundException e) {
log.error("Error adding view resource permission to navigation resource type", e);
}
}
#Override
public void beforePhase(PagePhaseEvent pagePhaseEvent) {
}
}
I am quite new to android development, I know the basics activities, maps, sqlite, etc.
I would like to be able to implement some 3D objects to be able to interact with within my apps. After a bit of searching I found that rajawali seems to be the best method. As you do I started with the first tutorial and reading the source code from the example docs.
Where I have become lost is I have followed the tutorial word for word and and I cant run the application due to errors in the script. If anybody has used Rajawali before I would appreiate some pointers as to where I have gone wrong. (the tutorial was last updated 2 month ago so its quite recent). Tutorial
Here is my source code
MainActivity:
package rajawali.tutorials;
import rajawali.RajawaliActivity;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends RajawaliActivity {
private Renderer mRenderer;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mRenderer = new Renderer(this);
mRenderer.setSurfaceView(mSurfaceView);
super.setRenderer(mRenderer);
}
}
Renderer:
package rajawali.tutorials;
import javax.microedition.khronos.opengles.GL10;
import android.content.Context;
import rajawali.lights.DirectionalLight;
import rajawali.materials.textures.ATexture.TextureException;
import rajawali.materials.textures.Texture;
import rajawali.primitives.Sphere;
import rajawali.renderer.RajawaliRenderer;
public class Renderer extends RajawaliRenderer {
private DirectionalLight mLight;
Sphere mSphere;
public Renderer(Context context) {
super(context);
setFrameRate(60);
}
public void initScene() {
mLight = new DirectionalLight(1f, 0.2f, -1.0f);
mLight.setColor(1.0f, 1.0f, 1.0f);
mLight.setPower(2);
try {
*DiffuseMaterial* material = new *DiffuseMaterial*(); //there is an error here (DiffuseMaterial cannot be rsolved as a type)
material.addTexture(new *Texture(R.drawable.earthtruecolor_nasa_big)*); //here (constructor Texture(int) cannot be defined)
mSphere = new Sphere(1, 24, 24);
mSphere.setMaterial(material);
mSphere.*addLight(mLight)*; //and here (The method addLight(DirectionalLight) is undefined for the type Sphere)
addChild(mSphere);
} catch (TextureException e) {
e.printStackTrace();
}
getCurrentCamera().setZ(4.2f);
}
#Override
public void onDrawFrame(GL10 glUnused) {
super.onDrawFrame(glUnused);
mSphere.setRotY(mSphere.getRotY() + 1);
}
}
I don't realy want to be spoon feed code if I can help it but it appears that the error is in the 'DiffuseMaterial'. Why is this or is there a better way of manipulating 3D objects other than using min3D or Rajawali?
I also have been trying to run this rajawali tutorial using next code.
Class RajawaliTutorialActivity
package rajawali.tutorials;
import rajawali.RajawaliActivity;
import android.os.Bundle;
public class RajawaliTutorialActivity extends RajawaliActivity {
public RajawaliTutorialRenderer mRenderer;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mRenderer = new RajawaliTutorialRenderer(this);
mRenderer.setSurfaceView(mSurfaceView);
super.setRenderer(mRenderer);
}
}
Class RajawaliTutorialRenderer
package rajawali.tutorials;
import javax.microedition.khronos.opengles.GL10;
import android.content.Context;
import rajawali.Camera;
import rajawali.Object3D;
import rajawali.lights.DirectionalLight;
import rajawali.materials.Material;
import rajawali.materials.textures.ATexture.TextureException;
import rajawali.materials.textures.Texture;
import rajawali.primitives.Sphere;
import rajawali.renderer.RajawaliRenderer;
public class RajawaliTutorialRenderer extends RajawaliRenderer {
public DirectionalLight light;
public Object3D sphere;
public Context context;
public Camera camera;
public RajawaliTutorialRenderer(Context context) {
super(context);
this.context = context;
setFrameRate(60);
}
public void initScene() {
light = new DirectionalLight(1f, 0.2f, -1.0f); // set the direction
light.setColor(1.0f, 1.0f, 1.0f);
light.setPower(2);
try{
Material material = new Material();
material.addTexture(new Texture("earthColors", R.drawable.earthtruecolor_nasa_big));
material.setColorInfluence(0);
sphere = new Sphere(1, 24, 24);
sphere.setMaterial(material);
getCurrentScene().addLight(light);
super.addChild(sphere);
} catch (TextureException e){
e.printStackTrace();
}
getCurrentCamera().setZ(4.2f);
}
#Override
public void onDrawFrame(GL10 glUnused) {
super.onDrawFrame(glUnused);
sphere.setRotY(sphere.getRotY() + 1);
}
}
See that changes are:
declare sphere object as Object3D instead Sphere.
change DiffuseMaterial by Material for material declaration.
change parameters to get Texture. First parameter is an custom identifier and second parameter is the resource id.
add the line material.setColorInfluence(0); after load texture, if this line isn't added, the "heart" becomes red (I'm not sure why).
replace sphere object by scene object (accessing with getCurrentScene method) to call addLight method.
Add try/catch for line material.addTexture() as this method now throws a TextureException
add getCurrentCamera().setZ(4.2f); to the end of initScene
It looks like this has to do with the version of Rajawali.
On this page it says not to use the master branch:
Whether you choose to clone or download, you probably will want to use one of the release tags. The master branch of both the library and examples is used for development and should be considered unstable for production code. When we release a stable version, it will be tagged. If you are cloning, you can simply checkout a tag.
If you cloned Rajawali using git, you'll want to checkout from a tag. To list the tags:
$ git tag
v0.9
At the time of writing, v0.9 is your only choice.
$ git checkout v0.9
Now you'll have DiffuseMaterial available. However, some of the other classes are still missing.
EDIT:
It looks like this tutorial neither applies to v0.9 nor the latest master branch. I made a working version of tutorial 1, which you can find linked here.
You can also use the RajawaliExamples application I wrote, which is composed of contributed examples, as a demonstration of using the master branch.
https://github.com/MasDennis/RajawaliExamples
Also to clarify on Deans quote, the statement made there is dissuade people from freaking out when the API changed underneath them which was mostly relevant when jwoolston was making large changes to support scene graphs. The bulk of that work is done and if ever finished, the api is likely to change significantly from its current state as the other major items are already complete. Such items are pieces like animation, more parsing options, flexible rendering, etc.