spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

How to halt a clip/object in a certain time?


The way I understand your question, you can use a LineListener.

Just, for example, here is a class that goes through a List, playing the next stream each time the current one completes:

class Playlist implements LineListener
{
    private final List<AudioInputStream>
list = new ArrayList<>();
    private Clip clip;
    private int next;

    @Override
    public void update(LineEvent evt) {
        if(evt.getType() == LineEvent.STOP) {
            try {
                playNext();
            } catch(LineUnavailableException |
IOException e) {
                e.printStackTrace();
            }
        }
    }

    void enqueue(AudioInputStream ais) {
        synchronized(this) {
            list.add(ais);
        }
    }

    void playNext() throws
LineUnavailableException, IOException {
        synchronized(this) {
            if(list.isEmpty()) {
                throw new IllegalStateException();
            }
            if(clip != null) {
                if(clip.isRunning()) clip.stop();
                if(clip.isOpen()) clip.close();
            }

            clip = AudioSystem.getClip();
            clip.addLineListener(listener);
            try {
                clip.open(list.get(next));
            } finally {
                next = (next + 1) % list.size();
            }
            clip.start();
        }
    }
}

Categories : Java

Related to : How to halt a clip/object in a certain time?
Error "Object.keys called on non-object" caused by empty json output
The error Object.keys called on non-object can only occured when you put non object into it. See below in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys return function(obj) { if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) { throw new TypeError('Object.keys called on non-object'); } Did you te

Categories : Javascript
Mapping Data Annotation of a Model object to Custom Class object .net mvc
As you have mentioned you can get attributes with the information from this question: How to retrieve Data Annotations from code? (programmatically) public static T GetAttributeFrom<T>(this object instance, string propertyName) where T : Attribute { var attrType = typeof(T); var property = instance.GetType().GetProperty(propertyName); return (T)property .GetCustomAttributes(attr

Categories : C#
AtrributeError: 'NoneType' object has no attribute 'data' & TypeError: 'str' object is not callable
You're trying to call string.lowercase(blabla) and that's where you get TypeError You should do print "In Boston, Lincolnshire it is currently: " + bostonweather['current_conditions']['text'].lower() + " and " + bostonweather['current_conditions']['temperature'].lower() + ("C. ")

Categories : Python
RenderSection set as required:false, but still throws "Object reference not set to an instance of an object"
This has nothing to do with your section. I'm not sure where you got the idea that the section being empty is generating this error, but that is categorically not what's happening. Object reference not set to an instance of an object is a runtime error generated when you attempt to reference a property off of a variable that evaluates to null. There's some piece of code somewhere that is referenci

Categories : Asp Net Mvc
ScrollViewer object to scroll to the bottom , Referring the ListView's child visual object in the ViewModel (MVVM)
If you bind SelectedItem to a property in your view model, the newly selected item should automatically be scrolled into view when the selection changes. If that behavior is not sufficient, you should keep the scrolling logic in the view; it does not belong in the view model, as it is specific to that particular view design. You may, however, want to add an event in your view model that your view

Categories : C#
Recently Add
Concurrent collection to 50/50 read/write
How to get unique members of object class (groupofUniqueNames) from an ldap server using java
Custom error reporting: how to log down function arguments (and possibly locals) in an exception handler?
Websphere MQ message redelivery
How to use BigDecimal to achieve following code instead of using double or float?
What exactly do the service() method of this HttpServlet?
Why does the Java API use int instead of short or byte?
Hibernate. One to one mapping without cross references
How to pass array to a java method
BooleanFieldEditor doesn't load value from PreferenceStore
NoClassDefFoundError when I call the class through commnad line
Shopizer Search
Java - Bank System + Transaction Function
Hadoop security using Apache DS / Apache Directory Studio
Multiple property-placeholder with overlapping locations does not work?
could not remove/add jpanel in jframe
Java garbage collection verbose not working
If child class has a variable with same name as private variable in parent what will be used?
Jackson parse json with a one-to-many relationship in a single step
Excel opens wrong view after generating in Apache POI
On Switch How to use logic operator on case JAVA
Java: What is the absolut first second in Calendar?
Waiting One Second for a button click, if button not clicked call function
Fastest way to extract part of a large JSON File
copy directory operation using linux command in java
Figuring out how to Format Printing
Why does @FunctionalInterface have a RUNTIME retention?
Collision detection Libgdx rectangles
Cannot find symbol in method changeRecL but declared in main method
Receiving "java.net.SocketException: Connection reset" when connecting from dotnet client to a java server
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.