Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Having problem to play sound second time

Having problem to play sound second time

All your problems with Audio, Video and Images.

Having problem to play sound second time

Postby xiaodar » Fri May 14, 2010 7:28 am

HI,
When i run my program for the 1st time the sound does play
however when i run my application 2nd time the sound does not play or it gets cut half way.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.google.zxing.client.android;
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11. import android.app.Activity;
  12.  
  13. import android.content.Intent;
  14.  
  15. import android.media.MediaPlayer;
  16.  
  17. import android.os.Bundle;
  18.  
  19. import android.os.CountDownTimer;
  20.  
  21. import android.view.View;
  22.  
  23. import android.widget.Button;
  24.  
  25. import android.widget.TextView;
  26.  
  27. import android.widget.Toast;
  28.  
  29.  
  30.  
  31.  
  32.  
  33. public class Main extends Activity {
  34.  
  35.        
  36.  
  37.         int test123 = 0;
  38.  
  39.         Button btnView;
  40.  
  41.         Button btnScan;
  42.  
  43.         Button Stop;
  44.  
  45.         TextView timeDisplay;
  46.  
  47.          String test1="15Min";
  48.  
  49.           String test2="30Min";
  50.  
  51.           String test3="60Min";
  52.  
  53.           int state = 0;
  54.  
  55.           int length = 10000;//100s
  56.  
  57.           long startTime = 0;
  58.  
  59.           long currentTime = 0;
  60.  
  61.           long timeElapsed = 0;
  62.  
  63.           long timeRemaining = 0;
  64.  
  65.           long prevTimeRemaining = 0;
  66.  
  67.            
  68.  
  69.          MyCount counter;
  70.  
  71.          
  72.  
  73.         String name2 = "";
  74.  
  75.        
  76.  
  77.     /** Called when the activity is first created. */
  78.  
  79.     @Override
  80.  
  81.     public void onCreate(Bundle savedInstanceState) {
  82.  
  83.         super.onCreate(savedInstanceState);
  84.  
  85.       setContentView(R.layout.main);
  86.  
  87.        
  88.  
  89.       btnView = (Button) findViewById(R.id.btnView);
  90.  
  91.    
  92.  
  93.       btnScan = (Button) findViewById(R.id.btnScan);
  94.  
  95.       Stop  = (Button) findViewById(R.id.Stop);
  96.  
  97.       timeDisplay = (TextView) findViewById(R.id.timer);
  98.  
  99.        
  100.  
  101.       name2=Test.test;
  102.  
  103.       counter = new MyCount(length, 100);
  104.  
  105.  
  106.  
  107.             if(name2.equals(test1))
  108.  
  109.             {
  110.  
  111.                 length =5000;
  112.  
  113.                
  114.  
  115.                 counter = new MyCount(length, 100);
  116.  
  117.                 startTime = System.currentTimeMillis();
  118.  
  119.                     counter.start();
  120.  
  121.             }
  122.  
  123.             if(name2.equals(test2))
  124.  
  125.             {
  126.  
  127.                 length = 1800000;
  128.  
  129.                 counter = new MyCount(length, 100);
  130.  
  131.                 startTime = System.currentTimeMillis();
  132.  
  133.                     counter.start();
  134.  
  135.             }
  136.  
  137.             if(name2.equals(test3))
  138.  
  139.             {
  140.  
  141.                 length = 3600000 ;
  142.  
  143.                 counter = new MyCount(length, 100);
  144.  
  145.                 startTime = System.currentTimeMillis();
  146.  
  147.                     counter.start();
  148.  
  149.             }
  150.  
  151.  
  152.  
  153.        
  154.  
  155.                
  156.  
  157.  
  158.  
  159.                 btnScan.setOnClickListener(new View.OnClickListener() {
  160.  
  161.  
  162.  
  163.                         public void onClick(View v) {
  164.  
  165.                          
  166.  
  167.                                 Intent myIntent = new Intent(((View) v).getContext(),CaptureActivity.class);
  168.  
  169.                         startActivityForResult(myIntent, 1);
  170.  
  171.                         }
  172.  
  173.                 });    
  174.  
  175.  
  176.  
  177.                 btnView.setOnClickListener(new View.OnClickListener() {
  178.  
  179.  
  180.  
  181.                         public void onClick(View v) {
  182.  
  183.                          
  184.  
  185.                                 Intent myIntent = new Intent(((View) v).getContext(),view.class);
  186.  
  187.                         startActivityForResult(myIntent, 1);
  188.  
  189.                         }
  190.  
  191.                 });    
  192.  
  193.                 Stop.setOnClickListener(new View.OnClickListener() {
  194.  
  195.  
  196.  
  197.                         public void onClick(View v) {
  198.  
  199.                                
  200.  
  201.                                
  202.  
  203.                                 counter.cancel();
  204.  
  205.                               timeDisplay.setText("");
  206.  
  207.                         }
  208.  
  209.                 });    
  210.  
  211.        
  212.  
  213.     }
  214.  
  215.     public class MyCount extends CountDownTimer {
  216.  
  217.  
  218.  
  219.             public MyCount(long millisInFuture, long countDownInterval) {
  220.  
  221.               super(millisInFuture, countDownInterval);
  222.  
  223.             }
  224.  
  225.  
  226.  
  227.             public void onFinish() {
  228.  
  229.                
  230.  
  231.               timeDisplay.setText("Your Coupon Time is up!");
  232.  
  233.              MediaPlayer mp = MediaPlayer.create(getBaseContext(), R.raw.sound);  
  234.  
  235.          
  236.  
  237.              mp.start();
  238.  
  239.        
  240.  
  241.             Toast.makeText(Main.this, "Your Coupon Time is up", Toast.LENGTH_SHORT).show();
  242.  
  243.             }
  244.  
  245.            
  246.  
  247.  
  248.  
  249.             public void onTick(long millisUntilFinished) {
  250.  
  251.                 //formatTime(length);
  252.  
  253.                
  254.  
  255.                       timeDisplay.setText("Left: " + formatTime(millisUntilFinished));
  256.  
  257.                
  258.  
  259.             }
  260.  
  261.     }
  262.  
  263.            
  264.  
  265.            
  266.  
  267.          
  268.  
  269.         public String formatTime(long millis) {
  270.  
  271.                   String output = "00:00:00";
  272.  
  273.                   long seconds = millis / 1000;
  274.  
  275.                   long minutes = seconds / 60;
  276.  
  277.                   long hours = minutes / 60;
  278.  
  279.  
  280.  
  281.                   seconds = seconds % 60;
  282.  
  283.                   minutes = minutes % 60;
  284.  
  285.                   hours = hours % 60;
  286.  
  287.  
  288.  
  289.                   String secondsD = String.valueOf(seconds);
  290.  
  291.                   String minutesD = String.valueOf(minutes);
  292.  
  293.                   String hoursD = String.valueOf(hours);
  294.  
  295.  
  296.  
  297.                   if (seconds < 10)
  298.  
  299.                     secondsD = "0" + seconds;
  300.  
  301.                   if (minutes < 10)
  302.  
  303.                     minutesD = "0" + minutes;
  304.  
  305.                   if (hours < 10)
  306.  
  307.                     hoursD = "0" + hours;
  308.  
  309.  
  310.  
  311.                   output = hoursD + " : " + minutesD + " : " + secondsD;
  312.  
  313.                   return output;
  314.  
  315.                 }
  316.  
  317.    
  318.  
  319.  
  320.  
  321.                    
  322.  
  323.         }
  324.  
  325.  
Parsed in 0.018 seconds, using GeSHi 1.0.8.4
xiaodar
Junior Developer
Junior Developer
 
Posts: 16
Joined: Wed Mar 24, 2010 9:51 am

Top

Re: Having problem to play sound second time

Postby dagonal » Thu May 20, 2010 4:55 pm

I think you may have the same problem I had...

Are you using a SoundManager class?

The problem I had was in the SoundManager class I pulled off the net was that the addSound method wasn't coded correctly, it didn't take the index and set everything to 1. So if you are using a SoundManager...please post the source.
dagonal
Freshman
Freshman
 
Posts: 2
Joined: Thu May 20, 2010 4:43 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 5 guests