File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed
Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 77using osuTK . Graphics ;
88using osu . Framework . Graphics . Shapes ;
99using osu . Framework . Allocation ;
10+ using osu . Framework . Audio . Track ;
11+ using osu . Framework . Graphics . Sprites ;
12+ using osu . Framework . Input . Events ;
1013
1114namespace SampleGame
1215{
1316 public partial class SampleGameGame : Game
1417 {
1518 private Box box = null ! ;
19+ private TrackBass bassTrack ;
20+ private SpriteText text ;
1621
1722 [ BackgroundDependencyLoader ]
1823 private void load ( )
1924 {
25+ bassTrack = ( TrackBass ) Dependencies . Get < ITrackStore > ( ) . Get ( "test.ogg" ) ;
26+ bassTrack . Start ( ) ;
27+
2028 Add ( box = new Box
2129 {
2230 Anchor = Anchor . Centre ,
2331 Origin = Anchor . Centre ,
2432 Size = new Vector2 ( 150 , 150 ) ,
2533 Colour = Color4 . Tomato
2634 } ) ;
35+
36+ Add ( text = new SpriteText ( )
37+ {
38+ Anchor = Anchor . Centre ,
39+ Origin = Anchor . Centre ,
40+ } ) ;
41+ }
42+
43+ protected override bool OnKeyDown ( KeyDownEvent e )
44+ {
45+ bassTrack . Stop ( ) ;
46+ bassTrack . Seek ( 200 ) ;
47+ bassTrack . Start ( ) ;
48+
49+ return base . OnKeyDown ( e ) ;
2750 }
2851
2952 protected override void Update ( )
3053 {
3154 base . Update ( ) ;
3255 box . Rotation += ( float ) Time . Elapsed / 10 ;
56+
57+ if ( bassTrack . CurrentTime < 100 )
58+ text . Text = bassTrack . CurrentTime . ToString ( ) ;
3359 }
3460 }
3561}
Original file line number Diff line number Diff line change @@ -335,7 +335,7 @@ private void updateCurrentTime()
335335 Debug . Assert ( CanPerformInline ) ;
336336
337337 long bytePosition = bassMixer . ChannelGetPosition ( this ) ;
338- if ( bytePosition != - 1 )
338+ // if (bytePosition != -1)
339339 Interlocked . Exchange ( ref currentTime , Bass . ChannelBytes2Seconds ( activeStream , bytePosition ) * 1000 ) ;
340340 }
341341
You can’t perform that action at this time.
0 commit comments