Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
head fork: btevfik/super-kids
Checking mergeability… Don't worry, you can still create the pull request.
  • 11 commits
  • 16 files changed
  • 0 commit comments
  • 3 contributors
Commits on Nov 07, 2012
@bduong bduong Added Javafx 34430b5
@bduong bduong changed target JDK to 1.7 02c09b4
Commits on Nov 08, 2012
Heng Du TutorialPanal changed, added creation of VideoPlayerPanel. Videoplaye…
…rPanel implemented, 3 video added into resources
0515d3b
Heng Du re commit TutorialPanel.java 8b8c4d5
@bduong bduong added xuggler dependency d9637da
@bduong bduong Merge branch 'javafx' into xuggler 0107f59
Commits on Nov 12, 2012
@bduong bduong xuggle 1e9421b
Commits on Nov 14, 2012
@bduong bduong added to UI, might have a thread problem 671b058
Commits on Nov 28, 2012
@bduong bduong fixed conflict
Merge branch 'master' of github.com:bduong/super-kids into xuggler

Conflicts:
	pom.xml
f162fc7
Commits on Dec 08, 2012
wongf Updated POM file for xuggler 5.2 to 5.4 2ca86ad
Commits on Dec 09, 2012
wongf tutorial support for new levels and subjects dc70f0f
View
17 GUI/pom.xml
@@ -14,6 +14,7 @@
<name>User Interface</name>
<properties>
<mary.tts.version>5.1-SNAPSHOT</mary.tts.version>
+ <jfx.version>2.2</jfx.version>
</properties>
<repositories>
@@ -48,6 +49,7 @@
<version>1.6</version>
</dependency>
+ <!--TTS Dependencies-->
<dependency>
<groupId>marytts</groupId>
<artifactId>marytts-runtime</artifactId>
@@ -63,18 +65,30 @@
<artifactId>voice-cmu-slt-hsmm</artifactId>
<version>${mary.tts.version}</version>
</dependency>
+
+ <!--Video Player-->
+ <dependency>
+ <groupId>xuggle</groupId>
+ <artifactId>xuggle-xuggler</artifactId>
+ <version>5.4</version>
+ </dependency>
+
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.0.0</version>
<type>jar</type>
- </dependency>
+ </dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
@@ -125,5 +139,4 @@
</plugin>
</plugins>
</build>
-
</project>
View
2  GUI/src/main/java/superkidsapplication/controllers/GameController.java
@@ -127,7 +127,7 @@ public void continueGame() {
} else if (number == -1) {
user.getState().getCurrentLevel();
QuestionLevel lev = user.getState().getCurrentLevel();
- controller.addPanel(new SubjectSelectionPanel(lev));
+ controller.addPanel(new SubjectSelectionPanel(lev, false));
System.out.println("Cannot find saved question.");
}
} catch (IOException ex) {
View
2  GUI/src/main/java/superkidsapplication/controllers/PanelController.java
@@ -159,7 +159,7 @@ public void goToSubjectMenu() {
goBackOnePanel();
}
if(found==false){
- this.addPanel(new SubjectSelectionPanel(session.getLoggedInUser().getState().getCurrentLevel()));
+ this.addPanel(new SubjectSelectionPanel(session.getLoggedInUser().getState().getCurrentLevel(),false));
}
}
}
View
2  GUI/src/main/java/superkidsapplication/controllers/TutorialController.java
@@ -42,7 +42,7 @@ public void reset(){
}
//we need a better method where a new question is fetched in from the server when this method is called.
- public TutorialPanel createTutorialPanel(String category) {
+ public TutorialPanel createTutorialPanel(QuestionCategory category) {
TutorialPanel qPanel;
System.out.println("create tutorial panel");
qPanel = new TutorialPanel(category);
View
4 GUI/src/main/java/superkidsapplication/panels/MainFrame.java
@@ -201,7 +201,9 @@ private void QModeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:e
private void LearnModeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LearnModeActionPerformed
// TODO add your handling code here:
- SubjectSelectionPanel sPanel = new SubjectSelectionPanel();
+// SubjectSelectionPanel sPanel = new SubjectSelectionPanel();
+ NewGamePanel sPanel = new NewGamePanel("New Tutorial");
+
//add questionPanel
controller.addPanel(sPanel);
}//GEN-LAST:event_LearnModeActionPerformed
View
2  GUI/src/main/java/superkidsapplication/panels/NewGamePanel.form
@@ -56,7 +56,7 @@
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JLayeredPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JLayeredPaneSupportLayout$JLayeredPaneConstraintsDescription">
- <JLayeredPaneConstraints x="90" y="160" width="210" height="40" layer="0" position="-1"/>
+ <JLayeredPaneConstraints x="90" y="160" width="400" height="40" layer="0" position="-1"/>
</Constraint>
</Constraints>
</Component>
View
20 GUI/src/main/java/superkidsapplication/panels/NewGamePanel.java
@@ -6,6 +6,8 @@
import com.ece.superkids.questions.enums.QuestionLevel;
import java.awt.Color;
+import java.util.HashSet;
+import java.util.Set;
import superkidsapplication.controllers.PanelController;
/**
@@ -18,11 +20,19 @@
* Creates new form NewGamePanel
*/
private PanelController controller;
+ private boolean tutorial_flag = false;
public NewGamePanel() {
controller = PanelController.getInstance();
initComponents();
}
+
+ public NewGamePanel(String string) {
+ controller = PanelController.getInstance();
+ tutorial_flag = true;
+ initComponents();
+ jLabel1.setText(string);
+ }
/**
* This method is called from within the constructor to initialize the form.
@@ -46,7 +56,7 @@ private void initComponents() {
jLabel1.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 36)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText("New Game");
- jLabel1.setBounds(90, 160, 210, 40);
+ jLabel1.setBounds(90, 160, 400, 40);
jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);
level3Button.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 18)); // NOI18N
@@ -144,7 +154,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
//FOR EACH LEVEL I THINK WE SHOULD HAVE A DIFFERENT PANEL RATHER THAN USING THE SAME PANEL
private void level2ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_level2ButtonActionPerformed
// TODO add your handling code here:
- SubjectSelectionPanel sPanel = new SubjectSelectionPanel(QuestionLevel.LEVEL_2);
+ SubjectSelectionPanel sPanel = new SubjectSelectionPanel(QuestionLevel.LEVEL_2, tutorial_flag);
+
//add questionPanel
controller.addPanel(sPanel);
}//GEN-LAST:event_level2ButtonActionPerformed
@@ -153,14 +164,15 @@ private void level1ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
// TODO add your handling code here
//CATEGORIES PANEL COMES HERE.
//QUESTIONS PANEL WILL BE ACCESSED FROM CATEGORIESPANEL
- SubjectSelectionPanel sPanel = new SubjectSelectionPanel(QuestionLevel.LEVEL_1);
+ SubjectSelectionPanel sPanel = new SubjectSelectionPanel(QuestionLevel.LEVEL_1, tutorial_flag);
+
//add questionPanel
controller.addPanel(sPanel);
}//GEN-LAST:event_level1ButtonActionPerformed
private void level3ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_level3ButtonActionPerformed
// TODO add your handling code here:
- SubjectSelectionPanel sPanel = new SubjectSelectionPanel(QuestionLevel.LEVEL_3);
+ SubjectSelectionPanel sPanel = new SubjectSelectionPanel(QuestionLevel.LEVEL_3, tutorial_flag);
//add questionPanel
controller.addPanel(sPanel);
}//GEN-LAST:event_level3ButtonActionPerformed
View
35 GUI/src/main/java/superkidsapplication/panels/SubjectSelectionPanel.java
@@ -24,14 +24,14 @@
private PanelController controller;
private TutorialController factory2;
private QuestionLevel level;
- private boolean tutorial;
private Session session;
+ private boolean tutorial_flag = false;
private GameController gController;
/**
* Creates new form SubjectSelectionPanel
*/
- public SubjectSelectionPanel(QuestionLevel level) {
+/* public SubjectSelectionPanel(QuestionLevel level) {
this.setName("SubjectSelection");
controller = PanelController.getInstance();
gController = GameController.getInstance();
@@ -42,13 +42,19 @@ public SubjectSelectionPanel(QuestionLevel level) {
subject2.setText(level.getCategories().get(1).toString());
subject3.setText(level.getCategories().get(2).toString());
}
-
- public SubjectSelectionPanel() {
- this.setName("TutorialSelection");
- tutorial = true;
+*/
+ public SubjectSelectionPanel(QuestionLevel level,boolean tutorial) {
+// this.setName("TutorialSelection");
controller = PanelController.getInstance();
- factory2 = TutorialController.getInstance();
- this.level = level.LEVEL_1;
+ if (tutorial){
+ tutorial_flag = true;
+ factory2 = TutorialController.getInstance();
+ }
+ else{
+ gController = GameController.getInstance();
+ session = Session.aSession();
+ }
+ this.level = level;
initComponents();
subject1.setText(level.getCategories().get(0).toString());
subject2.setText(level.getCategories().get(1).toString());
@@ -148,10 +154,11 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
private void subject1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subject1ActionPerformed
// TODO add your handling code here:
- if (tutorial) {
+ if (tutorial_flag) {
factory2.reset();
- TutorialPanel q = factory2.createTutorialPanel(level.getCategories().get(0).toString());
+ TutorialPanel q = factory2.createTutorialPanel(level.getCategories().get(0));
controller.addPanel(q);
+ q.play();
} else {
gController.newSubject(level, 0);
}
@@ -159,9 +166,9 @@ private void subject1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
private void subject2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subject2ActionPerformed
// TODO add your handling code here:
- if (tutorial) {
+ if (tutorial_flag) {
factory2.reset();
- TutorialPanel q = factory2.createTutorialPanel(level.getCategories().get(0).toString());
+ TutorialPanel q = factory2.createTutorialPanel(level.getCategories().get(0));
controller.addPanel(q);
} else {
gController.newSubject(level, 1);
@@ -170,9 +177,9 @@ private void subject2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
private void subject3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subject3ActionPerformed
// TODO add your handling code here:
- if (tutorial) {
+ if (tutorial_flag) {
factory2.reset();
- TutorialPanel q = factory2.createTutorialPanel(level.getCategories().get(0).toString());
+ TutorialPanel q = factory2.createTutorialPanel(level.getCategories().get(0));
controller.addPanel(q);
} else {
gController.newSubject(level, 2);
View
95 GUI/src/main/java/superkidsapplication/panels/TutorialPanel.java
@@ -4,28 +4,72 @@
*/
package superkidsapplication.panels;
-import com.ece.superkids.*;
-import com.ece.superkids.questions.entities.Question;
import com.ece.superkids.questions.enums.QuestionCategory;
-import com.ece.superkids.questions.enums.QuestionLevel;
-import java.util.ArrayList;
-import java.util.List;
-import javax.swing.Icon;
-import superkidsapplication.controllers.TutorialController;
+
+import javax.swing.*;
+
+import superkidsapplication.video.VideoPlayer;
+
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
/**
*
* @author FRANKs
*/
-public class TutorialPanel extends javax.swing.JPanel {
+public class TutorialPanel extends javax.swing.JPanel implements ActionListener{
/**
* Creates new form TutorialPanel
*/
- public TutorialPanel(String category) {
- this.setName("Learning");
+ private static VideoPlayer player;
+ private String fileName;
+ private static JButton play;
+
+ public TutorialPanel(QuestionCategory category) {
+ this.setName("Learning");
initComponents();
- jLabel1.setText(category);
+ jLabel1.setText(category.toString());
+ player = new VideoPlayer();
+
+ play = new JButton("Play");
+ play.setBounds(80, 80, 40, 40);
+ play.addActionListener(this);
+ JPanel panel = player.getViewingPanel();
+ panel.setBackground(Color.BLACK);
+ panel.setBounds(80, 180, panel.getPreferredSize().width, panel.getPreferredSize().height);
+ jLayeredPane1.add(panel, JLayeredPane.PALETTE_LAYER);
+ jLayeredPane1.add(play, JLayeredPane.POPUP_LAYER);
+
+ switch (category) {
+ case SHAPES:
+ fileName = "/videos/shapes.mp4";
+ break;
+ case COLORS:
+ fileName = "/videos/colors.mp4";
+ break;
+ case ANIMALS:
+ fileName = "/videos/animals.mp4";
+ break;
+ default:
+ }
+
+ }
+
+ public void play() {
+ long time = System.currentTimeMillis();
+ SoundPanel sound = SoundPanel.getInstance();
+ sound.mController.stopMusic();
+ player.play(fileName);
+ System.out.println(System.currentTimeMillis() - time);
+ time = System.currentTimeMillis();
+ repaint();
+ System.out.println("Repaint");
+ player.run();
+ System.out.println(System.currentTimeMillis() - time);
+
}
/**
@@ -51,7 +95,8 @@ private void initComponents() {
jLabel1.setBounds(0, 90, 800, 60);
jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);
- jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/backgrounds/QuestionScreen.png"))); // NOI18N
+ jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/backgrounds/QuestionScreen.png"))); //
+ // NOI18N
jLabel2.setText("jLabel2");
jLabel2.setBounds(0, 0, 800, 600);
jLayeredPane1.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);
@@ -59,12 +104,12 @@ private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 800, javax.swing.GroupLayout.PREFERRED_SIZE)
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 800, javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE)
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE)
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
@@ -72,4 +117,22 @@ private void initComponents() {
private javax.swing.JLabel jLabel2;
private javax.swing.JLayeredPane jLayeredPane1;
// End of variables declaration//GEN-END:variables
+
+ public static void main(String [] args) {
+ JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ TutorialPanel panel = new TutorialPanel(QuestionCategory.SHAPES);
+ frame.add(panel);
+ frame.pack();
+ //play.setEnabled(false);
+ frame.setVisible(true);
+ panel.play();
+
+ //play.setEnabled(true);
+ }
+
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ play();
+ }
}
View
62 GUI/src/main/java/superkidsapplication/video/VideoPlayer.java
@@ -0,0 +1,62 @@
+package superkidsapplication.video;
+
+import com.xuggle.mediatool.IMediaReader;
+import com.xuggle.mediatool.ToolFactory;
+import com.xuggle.xuggler.ICodec;
+import com.xuggle.xuggler.IContainer;
+import com.xuggle.xuggler.IStream;
+import com.xuggle.xuggler.IStreamCoder;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+public class VideoPlayer {
+ IMediaReader reader;
+ public VideoViewer viewer;
+
+ public VideoPlayer() {
+ viewer = new VideoViewer();
+ }
+
+ public void play(String fileName) {
+ reader = ToolFactory.makeReader(getClass().getResource(fileName).toString());
+// IContainer container = reader.getContainer();
+// for (int num = 0; num < container.getNumStreams(); num++) {
+// IStream stream = container.getStream(num);
+// IStreamCoder codec = stream.getStreamCoder();
+// if (codec.getCodecType()== ICodec.Type.CODEC_TYPE_VIDEO) {
+// JPanel panel = viewer.getPanel();
+// panel.setPreferredSize(new Dimension(codec.getWidth(), codec.getHeight()));
+// panel.setBounds(80, 180, codec.getWidth(), codec.getHeight());
+// }
+// }
+ reader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
+ reader.addListener(viewer);
+
+
+ }
+
+ public void run() {
+ while (reader.readPacket() == null)
+ ;
+ }
+
+ public JPanel getViewingPanel() {
+ return (viewer == null) ? null : viewer.getPanel();
+ }
+
+ public static void main(String [] args) {
+ JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ VideoPlayer vp = new VideoPlayer();
+ frame.add(vp.viewer.getPanel());
+ frame.pack();
+ frame.setVisible(true);
+
+ vp.play("/videos/shapes.mp4");
+
+
+ }
+}
View
78 GUI/src/main/java/superkidsapplication/video/VideoViewer.java
@@ -0,0 +1,78 @@
+package superkidsapplication.video;
+
+
+import com.xuggle.mediatool.MediaListenerAdapter;
+import com.xuggle.mediatool.event.IAudioSamplesEvent;
+import com.xuggle.mediatool.event.IVideoPictureEvent;
+import com.xuggle.xuggler.IAudioSamples;
+
+import javax.sound.sampled.*;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+public class VideoViewer extends MediaListenerAdapter {
+
+ private static int mVideoStreamIndex = -1;
+ private JPanel panel;
+ private BufferedImage image;
+ private SourceDataLine audio;
+
+ public VideoViewer() {
+ image = new BufferedImage(640, 400, BufferedImage.TYPE_3BYTE_BGR);
+ this.panel = new JPanel() {
+ @Override
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ g.drawImage(image, 0, 0, null); // see javadoc for more info on the parameters
+ }
+ };
+ panel.setPreferredSize(new Dimension(640,400));
+ }
+
+ public JPanel getPanel() {
+ return panel;
+ }
+
+ @Override
+ public void onVideoPicture(IVideoPictureEvent event) {
+ if (event.getStreamIndex() != mVideoStreamIndex) {
+ // if the selected video stream id is not yet set, go ahead an
+ // select this lucky video stream
+ if (mVideoStreamIndex == -1)
+ mVideoStreamIndex = event.getStreamIndex();
+ // no need to show frames from this video stream
+ else
+ return;
+ }
+ System.out.println("Hello");
+ image = event.getImage();
+ panel.repaint();
+ }
+
+ @Override
+ public void onAudioSamples(final IAudioSamplesEvent event) {
+ IAudioSamples samples = event.getAudioSamples();
+ if( audio == null) {
+ try {
+ AudioFormat format = new AudioFormat(samples.getSampleRate(), (int) samples.getSampleBitDepth(),
+ samples.getChannels(), true, false);
+
+ DataLine.Info info = new DataLine.Info(SourceDataLine.class,
+ format);
+
+ audio = (SourceDataLine) AudioSystem.getLine(info);
+ audio.open(format);
+ audio.start();
+
+ } catch (LineUnavailableException e) {
+ e.printStackTrace();
+ }
+ }
+ if(audio != null) {
+ int size = samples.getSize();
+ audio.write(samples.getData().getByteArray(0, size), 0, size);
+ }
+ }
+
+}
View
BIN  GUI/src/main/resources/videos/animals.mp4
Binary file not shown
View
BIN  GUI/src/main/resources/videos/colors.mp4
Binary file not shown
View
BIN  GUI/src/main/resources/videos/shapes.mp4
Binary file not shown
View
13 pom.xml
@@ -17,6 +17,10 @@
<repositories>
<repository>
+ <id>xuggle-repo</id>
+ <url>http://xuggle.googlecode.com/svn/trunk/repo/share/java/</url>
+ </repository>
+ <repository>
<id>Dropbox</id>
<url>https://dl.dropbox.com/u/2469167/mvn-repo</url>
</repository>
@@ -43,6 +47,15 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
</plugin>
View
6 server/pom.xml
@@ -34,6 +34,10 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
@@ -46,7 +50,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<configuration>
- <outputDirectory> ${project.build.directory}/surefire-reports </outputDirectory>
+ <outputDirectory>${project.build.directory}/surefire-reports</outputDirectory>
</configuration>
<executions>
<execution>

No commit comments for this range

Something went wrong with that request. Please try again.