@@ -543,7 +543,7 @@ static async Task<byte[]> GetBytesFromMetadataArtworkUrl(string url, Cancellatio
543543 {
544544 return [ ] ;
545545 }
546-
546+
547547 Stream ? stream = null ;
548548 Uri . TryCreate ( url , UriKind . Absolute , out var uri ) ;
549549
@@ -554,7 +554,7 @@ static async Task<byte[]> GetBytesFromMetadataArtworkUrl(string url, Cancellatio
554554
555555 // HTTP or HTTPS URL
556556 if ( uri is not null &&
557- ( uri . Scheme == Uri . UriSchemeHttp || uri . Scheme == Uri . UriSchemeHttps ) )
557+ ( uri . Scheme == Uri . UriSchemeHttp || uri . Scheme == Uri . UriSchemeHttps ) )
558558 {
559559 var request = new HttpRequestMessage ( HttpMethod . Head , url ) ;
560560 var contentLengthResponse = await client . SendAsync ( request , HttpCompletionOption . ResponseHeadersRead , cancellationToken ) . ConfigureAwait ( false ) ;
@@ -567,15 +567,15 @@ static async Task<byte[]> GetBytesFromMetadataArtworkUrl(string url, Cancellatio
567567 else if ( uri is not null && uri . Scheme == Uri . UriSchemeFile )
568568 {
569569 var normalizedFilePath = NormalizeFilePath ( url ) ;
570-
570+
571571 stream = File . Open ( normalizedFilePath , FileMode . Create ) ;
572572 contentLength = await GetByteCountFromStream ( stream , cancellationToken ) ;
573573 }
574574 // Relative File Path
575575 else if ( Uri . TryCreate ( url , UriKind . Relative , out _ ) )
576576 {
577577 var normalizedFilePath = NormalizeFilePath ( url ) ;
578-
578+
579579 stream = Platform . AppContext . Assets ? . Open ( normalizedFilePath ) ?? throw new InvalidOperationException ( "Assets cannot be null" ) ;
580580 contentLength = await GetByteCountFromStream ( stream , cancellationToken ) ;
581581 }
@@ -607,7 +607,7 @@ static async Task<byte[]> GetBytesFromMetadataArtworkUrl(string url, Cancellatio
607607 await stream . DisposeAsync ( ) ;
608608 }
609609 }
610-
610+
611611 static string NormalizeFilePath ( string filePath ) => filePath . Replace ( '\\ ' , Path . DirectorySeparatorChar ) . Replace ( '/' , Path . DirectorySeparatorChar ) ;
612612
613613 static async ValueTask < long > GetByteCountFromStream ( Stream stream , CancellationToken token )
@@ -618,15 +618,15 @@ static async ValueTask<long> GetByteCountFromStream(Stream stream, CancellationT
618618 }
619619
620620 long countedStreamBytes = 0 ;
621-
621+
622622 var buffer = new byte [ 8192 ] ;
623623 int bytesRead ;
624-
624+
625625 while ( ( bytesRead = await stream . ReadAsync ( buffer , token ) ) > 0 )
626626 {
627627 countedStreamBytes += bytesRead ;
628628 }
629-
629+
630630 return countedStreamBytes ;
631631 }
632632 }
@@ -707,7 +707,7 @@ void StopService(in BoundServiceConnection boundServiceConnection)
707707 mediaMetaData . SetArtist ( MediaElement . MetadataArtist ) ;
708708 mediaMetaData . SetTitle ( MediaElement . MetadataTitle ) ;
709709 var data = await GetBytesFromMetadataArtworkUrl ( MediaElement . MetadataArtworkUrl , cancellationToken ) . ConfigureAwait ( true ) ;
710- if ( data != null && data . Length > 0 )
710+ if ( data is not null && data . Length > 0 )
711711 {
712712 mediaMetaData . SetArtworkData ( data , ( Java . Lang . Integer ) MediaMetadata . PictureTypeFrontCover ) ;
713713 }
0 commit comments