GetMimeType() public static method

public static GetMimeType ( string fileNameOrExt ) : string
fileNameOrExt string
return string
示例#1
0
        private async Task <object> GetPlaylistAsync(VideoStreamRequest request, string name)
        {
            var state = await GetState(request, CancellationToken.None).ConfigureAwait(false);

            var builder = new StringBuilder();

            builder.AppendLine("#EXTM3U");
            builder.AppendLine("#EXT-X-VERSION:3");
            builder.AppendLine("#EXT-X-TARGETDURATION:" + state.SegmentLength.ToString(UsCulture));
            builder.AppendLine("#EXT-X-MEDIA-SEQUENCE:0");

            var queryStringIndex = Request.RawUrl.IndexOf('?');
            var queryString      = queryStringIndex == -1 ? string.Empty : Request.RawUrl.Substring(queryStringIndex);

            var seconds = TimeSpan.FromTicks(state.RunTimeTicks ?? 0).TotalSeconds;

            var index = 0;

            while (seconds > 0)
            {
                var length = seconds >= state.SegmentLength ? state.SegmentLength : seconds;

                builder.AppendLine("#EXTINF:" + length.ToString(UsCulture));

                builder.AppendLine(string.Format("hlsdynamic/{0}/{1}.ts{2}",

                                                 name,
                                                 index.ToString(UsCulture),
                                                 queryString));

                seconds -= state.SegmentLength;
                index++;
            }

            builder.AppendLine("#EXT-X-ENDLIST");

            var playlistText = builder.ToString();

            return(ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary <string, string>()));
        }
示例#2
0
        private async Task <object> GetAsync(GetMasterHlsVideoStream request)
        {
            var state = await GetState(request, CancellationToken.None).ConfigureAwait(false);

            int audioBitrate;
            int videoBitrate;

            GetPlaylistBitrates(state, out audioBitrate, out videoBitrate);

            var appendBaselineStream  = false;
            var baselineStreamBitrate = 64000;

            var hlsVideoRequest = state.VideoRequest as GetMasterHlsVideoStream;

            if (hlsVideoRequest != null)
            {
                appendBaselineStream  = hlsVideoRequest.AppendBaselineStream;
                baselineStreamBitrate = hlsVideoRequest.BaselineStreamAudioBitRate ?? baselineStreamBitrate;
            }

            var playlistText = GetMasterPlaylistFileText(videoBitrate + audioBitrate, appendBaselineStream, baselineStreamBitrate);

            return(ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary <string, string>()));
        }
示例#3
0
 public HttpResult(IVirtualFile fileResponse, bool asAttachment)
     : this(fileResponse, MimeTypes.GetMimeType(fileResponse.Name), asAttachment)
 {
 }
示例#4
0
 public HttpResult(FileInfo fileResponse, bool asAttachment)
     : this(fileResponse, MimeTypes.GetMimeType(fileResponse.Name), asAttachment)
 {
 }