Skip to content

Commit

Permalink
ビューアに読み込んだ画像をビューアのサイズに自動リサイズする処理を追加
Browse files Browse the repository at this point in the history
youtubeの動画プレイヤーサイズをオプションから指定出来るように変更
  • Loading branch information
ggslyman committed Mar 24, 2014
1 parent 88d1db8 commit efdc9b1
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 37 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

5. 字幕ボタンを押した状態だと字幕が音声再生と同時に表示されます。枠ボタンで表示領域を調整できます。

6. ステータスバーをクリックすると固定字幕入力欄が表示されます。

7. レス表示欄の画像リンク(末尾がjpg、gif、pngで終わるURL)とyoutubeリンクをクリックするとビューアが起動します。ビューアのタブをホイールクリックかダブルクリックでタブを閉じます。

##設定
 ツールバー右の設定ボタンを押すと各種設定を行うことができます。

Expand Down Expand Up @@ -95,6 +99,10 @@

##更新履歴

* 14/03/24 2.0.1 Rev.10
- ビューアに読み込んだ画像をビューアのサイズに自動リサイズする処理を追加
- youtubeの動画プレイヤーサイズをオプションから指定出来るように変更

* 14/03/24 2.0.1 Rev.9
- 自動次スレ移動時のスレタイ読み上げにその段階のレス数が含まれていた問題の修正
- レス取得時に末尾移動する機能の代わりにオートスクロール機能を追加
Expand Down
2 changes: 1 addition & 1 deletion SpeechCast/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2136,7 +2136,7 @@ private void oepnFormViewNewtabYoutube(string id)
formViewResource = new FormViewResource(UserConfig.FormViewToRect);
formViewResource.Show();
}
formViewResource.addTabYoutube(id);
formViewResource.addTabYoutube(id,UserConfig.ViewerYoutubePlayerWidth,UserConfig.ViewerYoutubePlayerHeight);
formViewResource.Activate();
}
// ビューア位置の保存
Expand Down
143 changes: 114 additions & 29 deletions SpeechCast/FormSettings.Designer.cs

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions SpeechCast/FormSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public void SetUserConfig(UserConfig userConfig)
this.checkBoxHideCaptionTitle.Checked = userConfig.HideCaptionTitle;
this.VoiceVolme = userConfig.SpeakingVolume;
this.checkBoxDebug.Checked = userConfig.OutputDebugLog;
numericUpDownViewerYoutubePlayerHeight.Value = userConfig.ViewerYoutubePlayerHeight;
numericUpDownViewerYoutubePlayerWidth.Value = userConfig.ViewerYoutubePlayerWidth;
UpdateUI();
}

Expand Down Expand Up @@ -196,6 +198,8 @@ public void GetUserConfig(UserConfig userConfig)
userConfig.AACaptionFont.Colors = this.aAFontColors;
userConfig.HideCaptionTitle = this.checkBoxHideCaptionTitle.Checked;
userConfig.OutputDebugLog = this.checkBoxDebug.Checked;
userConfig.ViewerYoutubePlayerHeight = (int)numericUpDownViewerYoutubePlayerHeight.Value;
userConfig.ViewerYoutubePlayerWidth = (int)numericUpDownViewerYoutubePlayerWidth.Value;
}


Expand Down
1 change: 1 addition & 0 deletions SpeechCast/FormViewResource.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 54 additions & 4 deletions SpeechCast/FormViewResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ private void FormViewResouce_Load(object sender, EventArgs e)
this.Height = rect.Height;
}

public void addTabYoutube(string id)
public void addTabYoutube(string id,int width,int height)
{
// コンテンツ格納用のWebブラウザを作成
WebBrowser wb = new WebBrowser();
// ウィジェットHTMLを生成
string widgetCode = "<iframe width=\"480\" height=\"360\" src=\"https://www.youtube.com/embed/" + id + "\" frameborder=\"0\" allowfullscreen></iframe>";
string widgetCode = "<iframe width=\"" + width.ToString() + "\" height=\"" + height.ToString() + "\" src=\"https://www.youtube.com/embed/" + id + "\" frameborder=\"0\" allowfullscreen></iframe>";
wb.DocumentText = "<body>" + widgetCode + "</body>";
wb.Dock = DockStyle.Fill;

// タブに表示するアイコン用画像ストリーム取得
WebClient wc = new WebClient();
string url = "http://img.youtube.com/vi/" + id + "/1.jpg";
FormMain.Instance.AddLog(url);
// FormMain.Instance.AddLog(url);
Stream stream = wc.OpenRead(url);
Bitmap bmp = new Bitmap(stream);
imgList.Images.Add(url, bmp);
Expand All @@ -62,7 +62,47 @@ public void addTabImg(string url)
{
// コンテンツ格納用のWebブラウザを作成
WebBrowser wb = new WebBrowser();
wb.Url = new Uri(url);
string imgHtml = "<img id=\"mainImg\" src=\"" + url + "\" />";
string js = @"<script type=""text/javascript"">
image = document.getElementById(""mainImg"");
var w = image.width , h = image.height ;
if ( typeof image.naturalWidth !== 'undefined' ) { // for Firefox, Safari, Chrome
w = image.naturalWidth;
h = image.naturalHeight;
} else if ( typeof image.runtimeStyle !== 'undefined' ) { // for IE
var run = image.runtimeStyle;
var mem = { w: run.width, h: run.height }; // keep runtimeStyle
run.width = ""auto"";
run.height = ""auto"";
w = image.width;
h = image.height;
run.width = mem.w;
run.height = mem.h;
} else { // for Opera
var mem = { w: image.width, h: image.height }; // keep original style
image.removeAttribute(""width"");
image.removeAttribute(""height"");
w = image.width;
h = image.height;
image.width = mem.w;
image.height = mem.h;
}
var ImgAspectRatio = w/h;
ImageChange();
function ImageChange(){
var AspectRatio = document.body.clientWidth / document.body.clientHeight;
if(AspectRatio < ImgAspectRatio){
document.getElementById(""mainImg"").style.width = ""100%"";
document.getElementById(""mainImg"").style.height = """";
}else{
document.getElementById(""mainImg"").style.width = """";
document.getElementById(""mainImg"").style.height = ""100%"";
}
}
window.onresize = ImageChange;
</script>
";
wb.DocumentText = "<body>" + imgHtml + js + "</body>";
wb.Dock = DockStyle.Fill;
// タブに表示するアイコン用画像ストリーム取得
WebClient wc = new WebClient();
Expand Down Expand Up @@ -110,5 +150,15 @@ private void FormViewResource_Resize(object sender, EventArgs e)
FormMain.Instance.saveViewerPos(this);
}

private void tabControlContainer_DoubleClick(object sender, EventArgs e)
{
TabPage rmPage = this.tabControlContainer.TabPages[tabControlContainer.TabIndex];
this.tabControlContainer.TabPages.Remove(this.tabControlContainer.TabPages[tabControlContainer.TabIndex]);
// タブを消しただけだとページがメモリ上に残るのでdisposeする
rmPage.Dispose();
// タブが無くなったらフォーム自体を閉じる
if (this.tabControlContainer.TabCount == 0) this.Close();
}

}
}
4 changes: 2 additions & 2 deletions SpeechCast/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.1.9")]
[assembly: AssemblyFileVersion("2.0.1.9")]
[assembly: AssemblyVersion("2.0.1.10")]
[assembly: AssemblyFileVersion("2.0.1.10")]
9 changes: 8 additions & 1 deletion SpeechCast/UseConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,14 @@ public void SupplementSettings()
/// イメージビューアのウィンドウ位置
/// </summary>
public Rectangle FormViewToRect;


/// <summary>
/// イメージビューアのyoutubeガジェットの表示サイズ
/// </summary>
public int ViewerYoutubePlayerHeight = 360;
public int ViewerYoutubePlayerWidth = 480;


/// <summary>
/// 自動スクロールONOFF
/// </summary>
Expand Down

0 comments on commit efdc9b1

Please sign in to comment.