예제 #1
0
파일: Player.cs 프로젝트: daisy/obi
 /// <summary>
 /// Play an asset from a specified time position its to end
 /// </summary>
 public void Play(urakawa.media.data.audio.AudioMediaData audio, double from)
 {
     if (this.state == PlayerState.Stopped || this.state == PlayerState.Paused)
     {
         if (audio != null && audio.getAudioDuration().getTimeDeltaAsMillisecondFloat() > 0)
         {
             urakawa.media.data.audio.PCMFormatInfo info = audio.getPCMFormat();
             int position = CalculationFunctions.AdaptToFrame(
                 CalculationFunctions.ConvertTimeToByte(from, (int)info.getSampleRate(), info.getBlockAlign()),
                 info.getBlockAlign());
             if (position >= 0 && position <= audio.getPCMLength())
             {
                 this.startPosition = position;
                 InitPlay(audio, position, 0);
             }
             else
             {
                 throw new Exception("Start Position is out of bounds of Audio Asset");
             }
         }
     }
 }
예제 #2
0
 // Compute the necessary width for the amount of audio at the current audio scale.
 private int WidthForAudio(urakawa.media.data.audio.AudioMediaData audio)
 {
     return((int)Math.Round(this.zoom * (audio == null ? this.baseSize.Width :
                                         this.audioScale * audio.getAudioDuration().getTimeDeltaAsMillisecondFloat())));
 }