surfaceview

how to clear surface holder when media player is finished?

天涯浪子 提交于 2019-11-30 01:37:19
问题 I made a video player with surfaceview and mediaplayer. i have 10 videos and 10 buttons. if click on each buttons, each videos are playing. here is my code.. //onCreate holder = surfaceview.getHolder(); holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); //Button1 if(mp == null)mp = new MediaPlayer(); mp.setDataSource(mediaplay_path); mp.setDisplay(holder); mp.setScreenOnWhilePlaying(true); mp.setAudioStreamType(AudioManager.STREAM_MUSIC); mp.prepare(); mp.start

The surface has been released when I try to setDisplay to MediaPlayer

穿精又带淫゛_ 提交于 2019-11-30 00:43:38
问题 My xml file: <SurfaceView android:id="@+id/surfaceView" android:layout_marginTop="50dp" android:layout_width="fill_parent" android:layout_height="300dp" /> My function to setDisplay: public void playVideo() { MediaPlayer mp = new MediaPlayer(); SurfaceView sv = (SurfaceView) this.findViewById(R.id.surfaceView); try { mp.setDataSource("sdcard/test/a.3gp"); SurfaceHolder sh = sv.getHolder(); mp.setDisplay(sh);***----the exception occured here*** mp.prepare(); mp.start(); } catch

Programming with SurfaceView and thread strategy for game development

若如初见. 提交于 2019-11-30 00:28:01
I am using a SurfaceView and a rendering thread to develop a game based on structure like LunarLander. However, I faced many problems, and here I want to point them all out. I wish anyone who want to develop a game won't need to struggle with them anymore. And anyone who have a better idea of the structure can share their experiences, because I am still new to android and is eager to learn :) [1] The function thread.start() should not be called more than once. Many articles mentioned to create a thread when surface is created, in order to render again after activity paused using the method :

VideoView on top of SurfaceView

心不动则不痛 提交于 2019-11-29 23:58:15
问题 I try to show a VideoView on top of a SurfaceView . But it isn't visible but reacts on clicks (MediaController appears and the sound plays). The video seems to be played behind the SurfaceView so I also tried to make use of setZOrderMediaOverlay() and/or setZOrderOnTop() but nothing changed When I go to the home screen I see the VideoView for a split second in the fading animation, so it is really there. I tried it with a xml layout and also completely programmatically but nothing works. Here

MediaPlayer skips forward about 6 seconds on rotation

蓝咒 提交于 2019-11-29 23:23:20
I have a MediaPlayer in a Fragment which retains its instance on configuration changes. The player is playing a video loaded from my assets directory. I have the scenario set up with the goal of reproducing the YouTube app playback where the audio keeps playing during the configuration changes and the display is detached and reattached to the media player. When I start the playback and rotate the device, the position jumps forward about 6 seconds and (necessarily) the audio cuts out when this happens. Afterwards, the playback continues normally. I have no idea what could be causing this to

What's differences between Surfaceview and TextureView?

眉间皱痕 提交于 2019-11-29 22:57:00
I've been studying Android especially View system. I have a question differences between them but there is no documents or references in my mother language. So I want to know from you guys. TextureView A TextureView can be used to display a content stream. Such a content stream can for instance be a video or an OpenGL scene. Example : https://github.com/dalinaum/TextureViewDemo Document: http://developer.android.com/reference/android/view/TextureView.html SurfaceView Provides a dedicated drawing surface embedded inside of a view hierarchy. Examples : http://www.mindfiresolutions.com/Using

SurfaceView in Layout

限于喜欢 提交于 2019-11-29 18:36:33
问题 So I've done a lot of searching but still can't seem to find the exact reason as to why my SurfaceView won't display. Here's a little background as to what I'm doing: I have a Linear Layout that is set Horizontally. It contains an ImageView, then a vertical Linear Layout, and finally another ImageView. In the vertical Linear Layout, there are essential three things: another ImageView at the top, an extended SurfaceView (called MagnetView) and an ImageView below that. Here's the xml:

Canvas and surfaceView example crash/freeze - Memory Leak?

馋奶兔 提交于 2019-11-29 18:12:37
http://www.helloandroid.com/tutorials/how-use-canvas-your-android-apps-part-1 At the end of this tutorial link for source code download is available. I downloaded the code and tried this example , It draws a kangaroo in the screen and within 1-2 minutes i get a crash/the application froze. I tried on Archos 70 Internet Tablet. "I would like to know the reason, or if some thing is wrong in this " Here is the LogCat 04-13 17:03:24.089: DEBUG/ondraw(2070): lefutott 04-13 17:03:24.097: DEBUG/ondraw(2070): lefutott 04-13 17:03:24.113: DEBUG/ondraw(2070): lefutott 04-13 17:03:24.128: DEBUG/ondraw

Add custom view as a view of XML layout

走远了吗. 提交于 2019-11-29 16:52:48
The scenario is the following: I have an activity RunTrainingWorkoutsView that uses XML layout _run_workout.xml_ with some labels that are updated by CountDownTimer . Works fine... Now, apart from labels that are updated every sec by onTick() callback method of CountDownTimer object I want to add a custom surface view to my _run_workout.xml layout_ that would draw some arcs updated by the same onTick() method every second... my run_workout.xml: <training.timer.CounterClockView android:id="@+id/counter_clock_surface" android:layout_width="300dp" android:layout_height="240dp"> </training.timer

is canvas in android proportional on different devices

孤者浪人 提交于 2019-11-29 16:40:25
I am trying to make an app using canvas and a surfaceview, and I am worrying that in the future I would have many problems with it because I am not sure if the canvas is proportional with every device. currently I can only use my emulator since my phone's usb cable doesn't work(I know.. I have to get a new one..). anyways, i would like to know if the canvas would transfer my coordinates and make everything proportional, what I mean by that is that if i have something in point a, lets say (10, 10) on a device that the screen of it is 100 X 100 (this is just an example for easy calculation) it