Commit b8b5fef4 authored by Thomas Krex's avatar Thomas Krex

recording.settime() funktioniert generell:

	-loop wird unterbochen(adjusting =true)
	-messages sucht alle messages raus
	-pixel[] wird geupdated
	-tonspur wird gesetzt
	-bitmap wird erstellte (graphicsContext.refresh)
	-loop wird wieder gestartet (adjusting=false)
	
ist aber sehr langsam, stürzt  manchmal  ab 
parent fdeb17ec
......@@ -24,19 +24,17 @@ public final class R {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int action_settings=0x7f08000d;
public static final int add=0x7f08000c;
public static final int button_save=0x7f080008;
public static final int feedDetailsLv=0x7f08000a;
public static final int feed_list=0x7f080009;
public static final int action_settings=0x7f08000b;
public static final int add=0x7f08000a;
public static final int button_save=0x7f080006;
public static final int feedDetailsLv=0x7f080008;
public static final int feed_list=0x7f080007;
public static final int feedback_button=0x7f080002;
public static final int play_btn=0x7f080004;
public static final int playerView=0x7f080003;
public static final int progressBar=0x7f08000b;
public static final int stop_btn=0x7f080005;
public static final int progressBar=0x7f080009;
public static final int test_button=0x7f080000;
public static final int tx_name=0x7f080007;
public static final int tx_url=0x7f080006;
public static final int tx_name=0x7f080005;
public static final int tx_url=0x7f080004;
public static final int watch_button=0x7f080001;
}
public static final class layout {
......
......@@ -2,7 +2,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
android:orientation="horizontal" >
<ImageView
android:id="@+id/playerView"
......@@ -11,24 +11,4 @@
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
<Button
android:id="@+id/play_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="25dp"
android:layout_marginLeft="162dp"
android:text="play" />
<Button
android:id="@+id/stop_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/play_btn"
android:layout_alignBottom="@+id/play_btn"
android:layout_marginLeft="76dp"
android:layout_toRightOf="@+id/play_btn"
android:text="stop" />
</RelativeLayout>
\ No newline at end of file
......@@ -4,30 +4,28 @@ import java.io.File;
import java.io.IOException;
import tttclient.services.DownloadService;
import tttclient.ttt.GraphicsContext;
import tttclient.ttt.Recording;
import android.app.Activity;
import android.graphics.Bitmap;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.util.Log;
import android.view.Display;
import android.view.MotionEvent;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.MediaController.MediaPlayerControl;
import com.example.test.R;
public class PlayerActivity extends Activity {
public class PlayerActivity extends Activity implements MediaPlayerControl {
public String fileName;
public String filePath;
public ImageView imgV;
Bitmap bitmap;
Button playButton;
Button pauseButton;
Recording recording;
MediaPlayer audioPlayer;
private Recording recording;
private MediaPlayer audioPlayer;
private MediaController audioController;
@Override
public void onCreate(Bundle savedInstanceState) {
......@@ -39,41 +37,134 @@ public class PlayerActivity extends Activity {
File tttFile = new File(filePath + "/" + fileName + ".ttt");
File audioFile = new File(filePath + "/" + fileName + ".mp3");
// create audio player
audioPlayer = MediaPlayer.create(this, Uri.fromFile(audioFile));
try {
playButton = (Button) findViewById(R.id.play_btn);
pauseButton = (Button) findViewById(R.id.stop_btn);
Display display = getWindowManager().getDefaultDisplay();
int screenWidth = display.getWidth(); // deprecated
int screenHeight = display.getHeight(); // deprecated
recording = new Recording(tttFile, audioPlayer, imgV, screenWidth,
screenWidth);
playButton.setOnClickListener(new OnClickListener() {
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@Override
public void onClick(View v) {
recording.play();
// create audio player & control
audioController = new MediaController(this);
audioController.setMediaPlayer(this);
audioController.setAnchorView(imgV);
// final int topContainerId1 = getResources().getIdentifier(
// "mediacontroller_progress", "id", "android");
// final SeekBar seekbar = (SeekBar) audioController
// .findViewById(topContainerId1);
//
// seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
//
// @Override
// public void onStopTrackingTouch(SeekBar seekBar) {
// recording.adjusting = false;
// recording.sliderStateChanged(seekbar.getProgress());
//
// }
//
// @Override
// public void onStartTrackingTouch(SeekBar seekBar) {
// recording.adjusting = true;
//
// }
//
// @Override
// public void onProgressChanged(SeekBar seekBar, int progress,
// boolean fromUser) {
// seekTo(progress);
//
// }
// });
//
}
}
});
@Override
public boolean canPause() {
return true;
}
pauseButton.setOnClickListener(new OnClickListener() {
@Override
public boolean canSeekBackward() {
// TODO Auto-generated method stub
return false;
}
@Override
public void onClick(View v) {
recording.pause();
@Override
public boolean canSeekForward() {
// TODO Auto-generated method stub
return false;
}
}
});
@Override
public int getAudioSessionId() {
return audioPlayer.getAudioSessionId();
}
try {
@Override
public int getBufferPercentage() {
// TODO Auto-generated method stub
return 0;
}
recording = new Recording(tttFile, audioPlayer);
GraphicsContext graphicsContext = new GraphicsContext(imgV,
recording);
@Override
public int getCurrentPosition() {
return audioPlayer.getCurrentPosition();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@Override
public int getDuration() {
return audioPlayer.getDuration();
}
@Override
public boolean isPlaying() {
return audioPlayer.isPlaying();
}
@Override
public void pause() {
if (audioPlayer.isPlaying())
recording.pause();
}
@Override
public void seekTo(int pos) {
recording.sliderStateChanged(pos);
}
@Override
public void start() {
Log.d("MediaController", "start invoked");
if (recording != null)
recording.play();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (audioController != null)
audioController.show();
return false;
}
@Override
protected void onDestroy() {
super.onDestroy();
recording.stop();
recording = null;
audioPlayer.release();
}
}
// TeleTeachingTool - Presentation Recording With Automated Indexing
//
// Copyright (C) 2003-2008 Peter Ziewer - Technische Universit?t M?nchen
//
// This file is part of TeleTeachingTool.
//
// TeleTeachingTool is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// TeleTeachingTool is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with TeleTeachingTool. If not, see <http://www.gnu.org/licenses/>.
/*
* Created on 13.01.2006
*
* Author: Peter Ziewer, TU Munich, Germany - ziewer@in.tum.de
*/
package tttclient.messages;
import tttclient.ttt.Constants;
import tttclient.ttt.GraphicsContext;
import android.graphics.Color;
import android.graphics.Rect;
public abstract class Annotation extends Message {
// return the outer bounds of the annotation
abstract public Rect getBounds();
// add annotation to graphicContext
@Override
public void paint(GraphicsContext graphicsContext) {
graphicsContext.addAnnotation(this);
// update painting
// graphicsContext.refresh(getBounds());
}
// used for showing temporary annotations during painting
public boolean temporary;
// special thumbnail drawing if needed (to avoid ugly scaling)
// public void paintToThumbnail(Graphics2D graphics) {
// paint(graphics);
// }
abstract public boolean contains(int x, int y);
@Override
abstract public int getEncoding();
@Override
public String toString() {
return super.toString() + ": Annotation-"
+ Constants.encodingToString(getEncoding());
}
// MODMSG
/**
* get XML String for messaging
*/
abstract public String getXMLString();
/*******************************************************************************************************************
* Default Color Table for annotations *
******************************************************************************************************************/
public final static int White = 0;
public final static int DarkGray = 4;
public final static int Gray = 8;
public final static int LightGray = 12;
public final static int Black = 16;
public final static int Orange = 20;
public final static int Pink = 24;
public final static int Blue = 28;
public final static int Red = 32;
public final static int Green = 36;
public final static int Magenta = 40;
public final static int Yellow = 44;
public final static int Cyan = 48;
static public int[] annotationColors = {
Color.argb(255, 255, 255, 255),
// white
Color.argb(192, 255, 255, 255),
Color.argb(128, 255, 255, 255),
Color.argb(64, 255, 255, 255),
Color.argb(255, 64, 64, 64),
// darkGray
Color.argb(192, 64, 64, 64),
Color.argb(128, 64, 64, 64),
Color.argb(64, 64, 64, 64),
Color.argb(255, 128, 128, 128),
// gray
Color.argb(192, 128, 128, 128),
Color.argb(128, 128, 128, 128),
Color.argb(64, 128, 128, 128),
Color.argb(255, 192, 192, 192),
// lightGray
Color.argb(192, 192, 192, 192),
Color.argb(128, 192, 192, 192),
Color.argb(64, 192, 192, 192),
Color.argb(255, 0, 0, 0),
// black
Color.argb(192, 0, 0, 0),
Color.argb(128, 0, 0, 0),
Color.argb(64, 0, 0, 0),
Color.argb(255, 255, 200, 0),
// orange
Color.argb(192, 255, 200, 0),
Color.argb(128, 255, 200, 0),
Color.argb(64, 255, 200, 0),
Color.argb(255, 255, 175, 175),
// pink
Color.argb(192, 255, 175, 175),
Color.argb(128, 255, 175, 175),
Color.argb(64, 255, 175, 175),
Color.argb(255, 255, 0, 0),
// blue
Color.argb(192, 0, 0, 255),
Color.argb(128, 0, 0, 255),
Color.argb(64, 0, 0, 255),
Color.argb(255, 255, 0, 0),
// red
Color.argb(192, 255, 0, 0),
Color.argb(128, 255, 0, 0),
Color.argb(64, 255, 0, 0),
Color.argb(255, 0, 255, 0),
// green
Color.argb(192, 0, 255, 0),
Color.argb(128, 0, 255, 0),
Color.argb(64, 0, 255, 0),
Color.argb(255, 255, 0, 255),
// magenta
Color.argb(192, 255, 0, 255),
Color.argb(128, 255, 0, 255),
Color.argb(64, 255, 0, 255),
Color.argb(255, 255, 255, 0),
// TODO
// yellow
Color.argb(255, 255, 0, 192),
Color.argb(255, 255, 0, 128),
Color.argb(255, 255, 0, 64),
Color.argb(0, 255, 255, 255),
// cyan
Color.argb(0, 255, 255, 192),
Color.argb(0, 255, 255, 128),
Color.argb(0, 255, 255, 64),
Color.argb(0, 0, 153, 255),
// dark blue
Color.argb(0, 0, 153, 192),
Color.argb(0, 0, 153, 128),
Color.argb(0, 0, 153, 64),
Color.argb(102, 102, 255, 255),
// light blue
Color.argb(102, 102, 255, 192),
Color.argb(102, 102, 255, 128),
Color.argb(102, 102, 255, 64),
Color.argb(204, 204, 255, 255),
// very light blue
Color.argb(204, 204, 255, 192),
Color.argb(204, 204, 255, 128),
Color.argb(204, 204, 255, 64),
Color.argb(255, 102, 102, 255),
// light red
Color.argb(255, 102, 102, 192),
Color.argb(255, 102, 102, 128),
Color.argb(255, 102, 102, 64),
Color.argb(255, 204, 204, 255),
// very light red
Color.argb(255, 204, 204, 192),
Color.argb(255, 204, 204, 128),
Color.argb(255, 204, 204, 64),
Color.argb(0, 102, 0, 255),
// dark green
Color.argb(0, 102, 0, 192),
Color.argb(0, 102, 0, 128),
Color.argb(0, 102, 0, 64),
Color.argb(102, 255, 102, 255),
// light green
Color.argb(102, 255, 102, 192),
Color.argb(102, 255, 102, 128),
Color.argb(102, 255, 102, 64),
Color.argb(204, 255, 204, 255),
// very light green
Color.argb(204, 255, 204, 192),
Color.argb(204, 255, 204, 128),
Color.argb(204, 255, 204, 64),
Color.argb(102, 0, 102, 255),
// dark rose
Color.argb(102, 0, 102, 192),
Color.argb(102, 0, 102, 128),
Color.argb(102, 0, 102, 64),
Color.argb(255, 0, 255, 255),
// rose
Color.argb(255, 0, 255, 192),
Color.argb(255, 0, 255, 128),
Color.argb(255, 0, 255, 64),
Color.argb(255, 102, 255, 255),
// light rose
Color.argb(255, 102, 255, 192),
Color.argb(255, 102, 255, 128),
Color.argb(255, 102, 255, 64),
Color.argb(255, 204, 255, 255),
// very light rose
Color.argb(255, 204, 255, 192),
Color.argb(255, 204, 255, 128),
Color.argb(255, 204, 255, 64),
Color.argb(102, 102, 0, 255),
// dark yellow
Color.argb(102, 102, 0, 192),
Color.argb(102, 102, 0, 128),
Color.argb(102, 102, 0, 64),
Color.argb(255, 255, 102, 255),
// light yellow
Color.argb(255, 255, 102, 192),
Color.argb(255, 255, 102, 128),
Color.argb(255, 255, 102, 64),
Color.argb(255, 255, 204, 255),
// very light yellow
Color.argb(255, 255, 204, 192),
Color.argb(255, 255, 204, 128),
Color.argb(255, 255, 204, 64),
Color.argb(0, 0, 102, 255),
// dark turquoise
Color.argb(0, 0, 102, 192),
Color.argb(0, 0, 102, 128),
Color.argb(0, 0, 102, 64),
Color.argb(102, 255, 255, 255),
// light turquoise
Color.argb(102, 255, 255, 192),
Color.argb(102, 255, 255, 128),
Color.argb(102, 255, 255, 64),
Color.argb(204, 255, 255, 255),
// very light turquoise
Color.argb(204, 255, 255, 192),
Color.argb(204, 255, 255, 128),
Color.argb(204, 255, 255, 64),
Color.argb(153, 0, 255, 255),
// violet
Color.argb(153, 0, 255, 192),
Color.argb(153, 0, 255, 128),
Color.argb(153, 0, 255, 64),
Color.argb(102, 0, 153, 255),
// dark violet
Color.argb(102, 0, 153, 192),
Color.argb(102, 0, 153, 128),
Color.argb(102, 0, 153, 64),
Color.argb(153, 102, 255, 255),
// blueish light violet
Color.argb(153, 102, 255, 192),
Color.argb(153, 102, 255, 128),
Color.argb(153, 102, 255, 64),
Color.argb(204, 102, 255, 255),
// redish light violet
Color.argb(204, 102, 255, 192),
Color.argb(204, 102, 255, 128),
Color.argb(204, 102, 255, 64),
Color.argb(204, 102, 0, 255),
// light brown
Color.argb(204, 102, 0, 192),
Color.argb(204, 102, 0, 128),
Color.argb(204, 102, 0, 64),
Color.argb(255, 102, 51, 255),
// dark orange
Color.argb(255, 102, 51, 192),
Color.argb(255, 102, 51, 128),
Color.argb(255, 102, 51, 64),
Color.argb(255, 204, 153, 255),
// light orange
Color.argb(255, 204, 153, 192),
Color.argb(255, 204, 153, 128),
Color.argb(255, 204, 153, 64),
Color.