Ejemplo n.º 1
0
void ofxTLAudioTrack::update(){
	if(this == timeline->getTimecontrolTrack()){
		if(getIsPlaying()){
			if(player.getPosition() < lastPercent){
				ofxTLPlaybackEventArgs args = timeline->createPlaybackEvent();
				ofNotifyEvent(events().playbackLooped, args);
			}
			lastPercent = player.getPosition();
			
			//currently only supports timelines with duration == duration of player
			if(lastPercent < timeline->getInOutRange().min){
				//player.setPosition( timeline->getInOutRange().min );
				player.setPosition( positionForSecond(timeline->getInTimeInSeconds()) );
			}
			else if(lastPercent > timeline->getInOutRange().max){
				if(timeline->getLoopType() == OF_LOOP_NONE){
//					player.setPosition(timeline->getInOutRange().max);
					player.setPosition( positionForSecond(timeline->getInTimeInSeconds()) );
					stop();
				}
				else{
//					player.setPosition(timeline->getInOutRange().min);
					player.setPosition( positionForSecond(timeline->getOutTimeInSeconds()) );
				}
			}
			
			timeline->setCurrentTimeSeconds(player.getPosition() * player.getDuration());
		}
	}
	//cout << "audio track " << player.getPosition() << " timeline " << timeline->getPercentComplete() << endl;
}
Ejemplo n.º 2
0
void ofxTLAudioTrack::playbackLooped(ofxTLPlaybackEventArgs& args){
	if(isSoundLoaded() && this != timeline->getTimecontrolTrack()){
		if(!player.getIsPlaying()){
			player.play();
		}
		player.setPosition( positionForSecond(timeline->getCurrentTime()) );
	}
}
void ofxTLVideoTrack::playbackLooped(ofxTLPlaybackEventArgs& args){
	if(isLoaded() && this != timeline->getTimecontrolTrack() && playAlongToTimeline){
		if(!player->isPlaying()){
			player->play();
		}
		player->setPosition( positionForSecond(timeline->getCurrentTime()) );
	}
}
Ejemplo n.º 4
0
void ofxTLAudioTrack::playbackStarted(ofxTLPlaybackEventArgs& args){
	ofxTLTrack::playbackStarted(args);
	if(isSoundLoaded() && this != timeline->getTimecontrolTrack()){
		//player.setPosition(timeline->getPercentComplete());
		float position = positionForSecond(timeline->getCurrentTime());
		if(position < 1.0){
			player.play();
		}
		player.setPosition( position );
	}
}
void ofxTLVideoTrack::playbackStarted(ofxTLPlaybackEventArgs& args){
	ofxTLTrack::playbackStarted(args);
	if(isLoaded() && this != timeline->getTimecontrolTrack() && playAlongToTimeline){
		//player.setPosition(timeline->getPercentComplete());
		float position = positionForSecond(timeline->getCurrentTime());
		if(position < 1.0){
			player->setSpeed(1.0);
			player->play();
            currentlyPlaying = true;
		}
		player->setPosition( position );
	}
}
Ejemplo n.º 6
0
void ofxTLAudioTrack::play(){
	if(!player.getIsPlaying()){
		
//		lastPercent = MIN(timeline->getPercentComplete() * timeline->getDurationInSeconds() / player.getDuration(), 1.0);
		player.setLoop(timeline->getLoopType() == OF_LOOP_NORMAL);

		player.play();
		if(timeline->getTimecontrolTrack() == this){
			player.setPosition(positionForSecond(timeline->getCurrentTime()));
			ofxTLPlaybackEventArgs args = timeline->createPlaybackEvent();
			ofNotifyEvent(events().playbackStarted, args);
		}
	}
}
Ejemplo n.º 7
0
void ofxTLAudioTrack::play(){

	if(!player.isPlaying()){
        
//		lastPercent = MIN(timeline->getPercentComplete() * timeline->getDurationInSeconds() / player.getDuration(), 1.0);
		player.setLoop(timeline->getLoopType() == OF_LOOP_NORMAL);
		player.play();
		if(timeline->getTimecontrolTrack() == this){
			if(player.getPosition() == 1.0 || timeline->getPercentComplete() > .99){
                timeline->setCurrentTimeSeconds(0);
            }
            
            player.setPosition(positionForSecond(timeline->getCurrentTime()));
            //cout << " setting time to  " << positionForSecond(timeline->getCurrentTime()) << " actual " << player.getPosition() << endl;
            
			ofxTLPlaybackEventArgs args = timeline->createPlaybackEvent();
			ofNotifyEvent(events().playbackStarted, args);
		}
	}
}