I want to play the video as splash screen.I have implement the play video but it show the default control like play,pause and seek etc.I want to remove the
so that the after video finish I need to call the new activity.
MediaController mc = new MediaController(this);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
video.setMediaController(mc);
video.setVideoURI(uri);
video.setOnCompletionListener(this);
video.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View arg0, MotionEvent arg1) {
Toast.makeText(getApplicationContext(), "ontouch",Toast.LENGTH_LONG).show();
return true;
}
}) ;
and the main.xml
Thank in advance.
The answer was too simple
remove the line
video.setMediaController(mc);
because i did not want to use the control.
Thank you
Disable the touchable property in the layout.xml file:
<VideoView
android:layout_width="fill_parent"
android:id="#+id/videoView1"
android:layout_height="wrap_content"
android:clickable="false"/>
Hope that helps you
Now there is a Method called
setMediaController(MediaController mCtrl)
http://d.android.com/reference/android/widget/VideoView.html#setMediaController%28android.widget.MediaController%29
You can call this method and pass the argument as MediaController.hide()
Here is a Sample Code:
MediaController controller=MediaController(Context);
controller.hide();
VideoView videoView= (VideoView) findViewById(R.id.videoView1);
videoView.setMediaController(controller);
//try passing null here as well
Related
My problem is I want an actor to do an action (in this case a fade) and just after the end of the action, switch to the game screen. But the action is finished not complete, but quickly changed the game screen.
I want to wait to complete this action before changing the screen .. And in general, I wonder how I can make waiting instructions in the game, because it is sometimes good to want to allow some time before anything happens.
myActor.addAction(Actions.fadeIn(2));
setScreen(AnotherScreen);
Use the static imports for actions, way easier.
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
Actor.addAction(sequence(fadeOut(2f), run(new Runnable() {
public void run () {
System.out.println("Action complete!");
}
});
Put the code you want to run in the runnable.
For more info,
https://github.com/libgdx/libgdx/wiki/Scene2d#actions
What you have to do is create an Action subclass and override Action#act where you will call setScreen(AnotherScreen);.
Then, use Actions#sequence to wrap both actions into a single SequenceAction object.
Action switchScreenAction = new Action(){
#Override
public boolean act(float delta){
setScreen(AnotherScreen);
return true;
}
};
myActor.addAction(Actions.sequence(
Actions.fadeIn(2)
, switchScreenAction
));
For more info, check out: https://github.com/libgdx/libgdx/wiki/Scene2d#complex-actions
I started a project with libgdx and I have a GameStateManager for my GameStates Menu and Play.
If I run the project it shows the Menu and then I can click a button to open the Play GameState.
The Problem is, that when I ended the Game it should show the Menu State again, but I get a black screen. I tested if the render() method is started (with System.out...) and the render() method in Menu is starting.
I am not shure why I get a black screen when I "reopen" the Menu state. Maybe its not working because I use Box2D in Play but I dont know.
Here some code:
This is the method in Play which should open the Menu if the player is at the end:
public void playerEnded() {
gsm.setState(GameStateManager.MENU);
}
Maybe you can tell me, if I have to end box2d things or so.
I hope someone can help me, and if you want more code - no problem.
Your custom GameStateManager should extend this class:
http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Game.html
To change screens you should be using Game.setScreen(Screen screen)
Each different screen should be an implementation of Screen.
So the way it works in my libGDX projects is such that GameScreen extends Screen, and MenuScreen extends Screen. That way I can change what draws on what screen.
This all goes back to interfaces and polymorphism, so if you don't get those concepts, just give it a quick google and you'll get an idea what you need to do.
Chances are that your are defining a
Stack<GameState> gameStates
in your GameStateManager to manage your GameStates.
If so, you could do some reading on using a Stack. Anyway, here's what could do to solve your problem:
I'm assuming you have the following structure in your GamestateManager;
public void setState(int state){
popState();
pushState(state);
}
public void pushState(int state){
gameStates.push(getState(state));
}
public void popState(){
GameState g = gameStates.pop();
g.dispose();
}
private GameState getState(int state){
if(state == MENU) return new Menu(this);
if(state == PLAY) return new Play(this);
return null;
}
When you click your start button in your Menu-GameState, you'll want to launch the Play-GameState.
Now, instead of using the setState method, which removes the top state (pop) and then pushes the new state. Try using only the pushState method. This will put your new Play-GameState on top of your Menu-GameState in the GameState-Stack.
When you're done playing, you can pop your Play-GameState and the Menu-GameState should reappear. But this time it won't instantiate a new Object, but reuse the one you used when you started the game.
// in the Menu-GameState:
public void startPlay() {
gsm.pushState(GameStateManager.PLAY);
}
// in the Play-GameState:
public void playerEnded() {
gsm.popState();
}
This won't affect gameplay performance as you would render and update your game with only the GameState that is on top of the Stack, like this:
public void update(float dt) {
gameStates.peek().update(dt);
}
public void render() {
gameStates.peek().render();
}
The peek method takes the GameState from the top of the Stack, but leaves it there.
The only downside is that the Menu-Gamestate would stay in-memory during your Play-State.
Also, if this method works, you could still do it your way, but you should check the way your Menu-GameState is instantiated and identify problems when it's instantiated twice.
I implemented a similar StageManager in my game. If you are using viewports/cameras in your game, then it is likely that when you go back to your menu state, the viewport is still set to the Game state's viewport.
For my app, I had my State class have an activate() method which would be called whenever a state became the active state:
public void activate(){
stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
I tried using this method to show debug lines:
table.debug();
Table.drawDebug(stage);
except Table.drawDebug expects a parameter of type: ShapeRenderer.
any direction would be great
You may just use a new ShapeRender() as parameter if your code doesn't contain one.
You don't need to call table.drawDebug(), just table.debug() is enough
I think you're looking for this?
Table table;
Stage stage;
public void show() {
table = new Table();
table.debug();
...
stage = new Stage(...);
stage.add(table);
}
public void render(float delta) {
Table.drawDebug(stage);
}
You debug draw the entire stage, but only the elements where debug() was called initially to mark them for debugging.
I hope this helps you.
P.S. btw this is from the official TableLayout docs here which is a must read if you're gonna mess around with Tables (if you haven't done so already).
I am currently doing an application using Swing and i am stuck at a certain point. In my function, i have to link videos from a JList. The problem is i am not sure how to link the videos from the JList. I am using an OpenBrowser class to link the video to the internet. I did consider using JButton but i would have to hardcode it and that would be ugly. Is there any other alternatives to do this? I am in desperate need and would be eternally grateful to whoever that can help me.
Safa :)
If you don't want to open a browser with the video using a selection listener, you can consider the idea of launching it with a double click on a JList entry.
sample code
String[] items = {"i1", "i2", "i3", "i4"};
JList list = new JList(items);
list.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
JList list = (JList)evt.getSource();
if (evt.getClickCount() == 2) { //check if it is a Double-click
int index = list.locationToIndex(evt.getPoint());
// do whatever you want with the entry at that index
}
}
});
Desktp classes to browse some site (sample code):
if (desktop.isSupported(Desktop.Action.BROWSE)) {
URI uri = new URI("http://www.google.com");
desktop.browse(uri);
}
The desktop.browse() call will open your favourite browser with the given URL.
I am looking for an event that fires after an image's source property has been changed, and the image display object has loaded the new data. I thought the 'complete' event was the way to go, but it seems to fires as soon as the source has changed, BUT before the image is done loading. In the snippet below, I am trying to get the imgMap_completeHandler to fire once imgMap has been updated with the bytes from doExport().
public function doExport(bytes:ByteArray):void
{
FlexGlobals.topLevelApplication.addElement(this);
imgMap.source = bytes;
}
protected function imgMap_completeHandler(event:Event):void
{
var pngEncoder:PNGEncoder = new PNGEncoder();
var snapShot:ImageSnapshot = ImageSnapshot.captureImage(this,0,pngEncoder);
export = snapShot.data;
dispatchEvent(new Event("exportComplete"));
}
<s:Image id="imgMap" complete="imgMap_completeHandler(event)" width="100%" height="100%"/>
Have you tried to extend Image class and source method to do that?
You may only have to create a standard event just after the
public function source(....)
{
[super source...]
dispatchEvent(new Event('Loaded'));
}
Hope it helps!