seek

Write to the middle of an existing binary file c++

蹲街弑〆低调 提交于 2020-01-14 07:04:52
问题 I'm trying to open a binary file for writing without erasing the content. But I do not want to write to eof. I want to write to a specific position in file. Here is a litte example: ofstream out("test.txt", ios::binary | ios::app); for(int i = 0; i < 100; i++) out.put('_'); out.write("Hallo", 5); out.close(); ofstream out2("test.txt", ios::binary | ios::app); out2.seekp(10); out2.write("Welt", 4); out2.close(); If using app, seek doesn't work. If not using app opening file erases data. Does

Write to the middle of an existing binary file c++

大兔子大兔子 提交于 2020-01-14 07:04:52
问题 I'm trying to open a binary file for writing without erasing the content. But I do not want to write to eof. I want to write to a specific position in file. Here is a litte example: ofstream out("test.txt", ios::binary | ios::app); for(int i = 0; i < 100; i++) out.put('_'); out.write("Hallo", 5); out.close(); ofstream out2("test.txt", ios::binary | ios::app); out2.seekp(10); out2.write("Welt", 4); out2.close(); If using app, seek doesn't work. If not using app opening file erases data. Does

Issue with reading file on Windows Phone 8 SD card

和自甴很熟 提交于 2020-01-13 12:12:11
问题 I have problems reads the file on Windows Phone SD card. I get the valid Stream object using ExternalStorageFile.OpenForReadAsync. However any seek operation is ignored and position is not moved although the stream CanSeek property is true; private async void ReadFileOnSDCard(ExternalStorageFile file) { Stream stream = await file.OpenForReadAsync(); using (stream) { long curPos= stream.Seek(100, SeekOrigin.Begin); long pos = stream.Position; // both curPos and pos are 0. 回答1: I was fighting

c++ fastest way to read only last line of text file?

☆樱花仙子☆ 提交于 2020-01-08 17:18:09
问题 I would like to read only the last line of a text file (I'm on UNIX, can use Boost). All the methods I know require scanning through the entire file to get the last line which is not efficient at all. Is there an efficient way to get only the last line? Also, I need this to be robust enough that it works even if the text file in question is constantly being appended to by another process. 回答1: Use seekg to jump to the end of the file, then read back until you find the first newline. Below is

How can i change the position of a progressBar, after the duration of a videoView?

对着背影说爱祢 提交于 2020-01-06 09:55:06
问题 i have the following code: final SeekBar videoBar = (SeekBar) findViewById(R.id.videoBar); final VideoView videoView = (VideoView) findViewById(R.id.videoViewPaint); videoView.setVideoPath(videoPath); videoView.start(); videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { long duration = videoView.getDuration(); videoBar.setMax((int) duration); LogService.log("in runnable", "videoView duration= " + videoView.getDuration());

How can i change the position of a progressBar, after the duration of a videoView?

最后都变了- 提交于 2020-01-06 09:54:52
问题 i have the following code: final SeekBar videoBar = (SeekBar) findViewById(R.id.videoBar); final VideoView videoView = (VideoView) findViewById(R.id.videoViewPaint); videoView.setVideoPath(videoPath); videoView.start(); videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { long duration = videoView.getDuration(); videoBar.setMax((int) duration); LogService.log("in runnable", "videoView duration= " + videoView.getDuration());

How can i change the position of a progressBar, after the duration of a videoView?

不问归期 提交于 2020-01-06 09:54:29
问题 i have the following code: final SeekBar videoBar = (SeekBar) findViewById(R.id.videoBar); final VideoView videoView = (VideoView) findViewById(R.id.videoViewPaint); videoView.setVideoPath(videoPath); videoView.start(); videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { long duration = videoView.getDuration(); videoBar.setMax((int) duration); LogService.log("in runnable", "videoView duration= " + videoView.getDuration());

How to pass a binary file as stdin to a Docker containerized Python script using argparse?

家住魔仙堡 提交于 2020-01-06 05:38:09
问题 Update based on Anthony Sottile's Answer I re-implemented his solution to simplify the problem. Lets take Docker and Django out of the equation. The goal is to use Pandas to read excel by both of the following methods: python example.py - < /path/to/file.xlsx cat /path/to/file.xlsx | python example.py - where example.py is reproduced below: import argparse import contextlib from typing import IO import sys import pandas as pd @contextlib.contextmanager def file_ctx(filename: str) -> IO[bytes]

How to seek() then pause() with JWPlayer 5.4

℡╲_俬逩灬. 提交于 2020-01-02 03:53:28
问题 Does anyone know how to get JW PLayer v5.4 (either the Flash rendering or the HTML5 rendering) to pause after a seek() command? I'm trying to get the video to step 0.01 seconds forward or backward when a user clicks the fine-grain control buttons (or uses the left or right arrow keys). This is so they can snap a framegrab with better precision. I'm not sure if this is even possible but I've tried a few things with no luck. Such as the following: var stepTo = jwplayer("video_player")

Seeking in AAC streams on Android

旧巷老猫 提交于 2020-01-01 17:09:10
问题 I'm getting an AAC stream from a HTTP server and using that as the datasource for the MediaPlayer in Android. It plays perfectly fine, but when I try to execute mediaPlayer.seekTo(int position) I get the following errors about a million times: WARN/AACDecoder(13889): AAC decoder returned error -1, substituting silence WARN/AACDecoder(13889): AAC decoder returned error 10, substituting silence WARN/AACDecoder(13889): AAC decoder returned error 1, substituting silence This error happens on