/*
 * Copyright 2017 Nikita Shakarun
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.samsung.util;

import java.io.IOException;

public class AudioClip {
	public static final int TYPE_MIDI = 3;
	public static final int TYPE_MMF = 1;
	public static final int TYPE_MP3 = 2;

	public AudioClip(int i, String str) throws IOException {
	}

	public AudioClip(int i, byte[] bArr, int i2, int i3) {
	}

	public static boolean isSupported() {
		return false;
	}

	public void pause() {
	}

	public void play(int i, int i2) {
	}

	public void resume() {
	}

	public void stop() {
	}
}

@@ -13,16 +13,21 @@
 ght 2017
+-2018
  Nikita 
@@ -657,210 +657,652 @@
 on;%0A
-%0Apublic class AudioClip %7B%0A%09public static final int TYPE_MIDI = 3;%0A%09public static final int TYPE_MMF = 1;%0A%09public static final int TYPE_MP3 = 2;%0A%0A%09public AudioClip(int i, String str) throws IOException %7B
+import java.io.InputStream;%0A%0Aimport javax.microedition.media.Manager;%0Aimport javax.microedition.media.MediaException;%0Aimport javax.microedition.media.Player;%0Aimport javax.microedition.util.ContextHolder;%0A%0Apublic class AudioClip %7B%0A%09public static final int TYPE_MIDI = 3;%0A%09public static final int TYPE_MMF = 1;%0A%09public static final int TYPE_MP3 = 2;%0A%0A%09private Player player;%0A%0A%09public AudioClip(int type, java.lang.String filename) throws IOException %7B%0A%09%09try %7B%0A%09%09%09InputStream stream = ContextHolder.getResourceAsStream(null, filename);%0A%09%09%09player = Manager.createPlayer(stream, %22audio/midi%22);%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D
 %0A%09%7D%0A
@@ -1324,17 +1324,20 @@
 lip(int 
-i
+type
 , byte%5B%5D
@@ -1341,31 +1341,164 @@
 e%5B%5D 
-bArr, int i2, int i3) %7B
+audioData, int audioOffset, int audioLength) %7B%0A%09%09try %7B%0A%09%09%09player = Manager.createPlayer(null, null);%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D
 %0A%09%7D%0A
@@ -1550,12 +1550,11 @@
 urn 
-fals
+tru
 e;%0A%09
@@ -1575,24 +1575,109 @@
 d pause() %7B%0A
+%09%09try %7B%0A%09%09%09player.stop();%0A%09%09%7D catch (MediaException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A
 %09%7D%0A%0A%09public 
@@ -1694,48 +1694,367 @@
 int 
-i
+loop
 , int 
-i2) %7B%0A%09%7D%0A%0A%09public void resume() %7B
+volume) %7B%0A%09%09try %7B%0A%09%09%09if (loop == 0) %7B%0A%09%09%09%09loop = -1;%0A%09%09%09%7D%0A%09%09%09if (player.getState() == Player.STARTED) %7B%0A%09%09%09%09player.stop();%0A%09%09%09%7D%0A%09%09%09player.setLoopCount(loop);%0A%09%09%09player.start();%0A%09%09%7D catch (MediaException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%7D%0A%0A%09public void resume() %7B%0A%09%09try %7B%0A%09%09%09player.start();%0A%09%09%7D catch (MediaException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D
 %0A%09%7D%0A
@@ -2076,13 +2076,31 @@
 top() %7B%0A
+%09%09player.close();%0A
 %09%7D%0A%7D%0A

Implement AudioClip